├── settings.gradle
├── src
├── test
│ ├── resources
│ │ ├── artifacts
│ │ │ └── org
│ │ │ │ ├── quartz-scheduler
│ │ │ │ ├── quartz
│ │ │ │ │ ├── 2.3.0
│ │ │ │ │ │ └── quartz-2.3.0.jar
│ │ │ │ │ └── index.html
│ │ │ │ ├── quartz-jobs
│ │ │ │ │ ├── 2.3.0
│ │ │ │ │ │ └── quartz-jobs-2.3.0.jar
│ │ │ │ │ └── index.html
│ │ │ │ ├── internal
│ │ │ │ │ └── index.html
│ │ │ │ ├── index.html
│ │ │ │ ├── quartz-commonj
│ │ │ │ │ └── index.html
│ │ │ │ ├── quartz-backward-compat
│ │ │ │ │ └── index.html
│ │ │ │ ├── quartz-oracle
│ │ │ │ │ └── index.html
│ │ │ │ ├── quartz-weblogic
│ │ │ │ │ └── index.html
│ │ │ │ ├── quartz-jboss
│ │ │ │ │ └── index.html
│ │ │ │ └── quartz-parent
│ │ │ │ │ └── index.html
│ │ │ │ └── infinispan
│ │ │ │ └── page6.json
│ │ ├── repo1-maven-metadata.xml
│ │ ├── repo2-maven-metadata.xml
│ │ └── spring-core-maven-metadata.xml
│ └── java
│ │ └── io
│ │ └── spring
│ │ └── bomr
│ │ ├── upgrade
│ │ ├── version
│ │ │ ├── NumericQualifierDependencyVersionTests.java
│ │ │ ├── DependencyVersionTests.java
│ │ │ ├── ReleaseTrainDependencyVersionTests.java
│ │ │ └── ArtifactVersionDependencyVersionTests.java
│ │ ├── BomVersionsTests.java
│ │ ├── MavenMetadataVersionResolverTests.java
│ │ └── UpgradePolicyTests.java
│ │ ├── artifacts
│ │ ├── MavenCentralSearchArtifactsFinderTests.java
│ │ └── MavenRepositoryArtifactsFinderTests.java
│ │ └── CommandsTests.java
└── main
│ ├── resources
│ ├── META-INF
│ │ └── spring.factories
│ └── templates
│ │ └── bom-dependencies.mustache
│ └── java
│ └── io
│ └── spring
│ └── bomr
│ ├── upgrade
│ ├── UpgradeResolver.java
│ ├── VersionResolver.java
│ ├── Module.java
│ ├── Upgrade.java
│ ├── ProhibitedVersions.java
│ ├── StringToVersionRangeConverter.java
│ ├── Project.java
│ ├── UpgradeConfiguration.java
│ ├── version
│ │ ├── UnstructuredDependencyVersion.java
│ │ ├── LeadingZeroesDependencyVersion.java
│ │ ├── NumericQualifierDependencyVersion.java
│ │ ├── CombinedPatchAndQualifierDependencyVersion.java
│ │ ├── AbstractDependencyVersion.java
│ │ ├── DependencyVersion.java
│ │ ├── ArtifactVersionDependencyVersion.java
│ │ └── ReleaseTrainDependencyVersion.java
│ ├── ProjectName.java
│ ├── UpgradePolicy.java
│ ├── UpgradeCommandArguments.java
│ ├── UpgradeCommand.java
│ ├── BomVersions.java
│ ├── UpgradeProperties.java
│ ├── BomUpgrader.java
│ ├── MavenMetadataVersionResolver.java
│ ├── Bom.java
│ └── InteractiveUpgradeResolver.java
│ ├── github
│ ├── GitHub.java
│ ├── GitHubConfiguration.java
│ ├── Milestone.java
│ ├── GitHubRepository.java
│ ├── GitHubProperties.java
│ ├── StandardGitHubRepository.java
│ └── StandardGitHub.java
│ ├── artifacts
│ ├── ArtifactsConfiguration.java
│ ├── ArtifactsFinder.java
│ ├── MavenCentralSearchArtifactsFinder.java
│ ├── ArtifactsCommand.java
│ ├── ArtifactsDeltaCommand.java
│ ├── ArtifactsCommandArguments.java
│ ├── MavenRepositoryArtifactsFinder.java
│ └── ArtifactsDeltaCommandArguments.java
│ ├── BomrProperties.java
│ ├── verify
│ ├── MavenProperties.java
│ ├── ManagedDependency.java
│ ├── VerifyProperties.java
│ ├── VerificationConfiguration.java
│ ├── Repository.java
│ ├── VerifyCommand.java
│ ├── VerifyCommandArguments.java
│ ├── MavenInvoker.java
│ ├── BomVerifier.java
│ └── VerifiableBom.java
│ ├── Command.java
│ ├── Commands.java
│ ├── UserHomeBomrPropertiesEnvironmentPostProcessor.java
│ └── BomrApplication.java
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .gitignore
├── config
└── checkstyle
│ ├── checkstyle-suppressions.xml
│ └── checkstyle.xml
├── launch.script
├── gradlew.bat
└── gradlew
/settings.gradle:
--------------------------------------------------------------------------------
1 | rootProject.name = 'bomr'
2 |
--------------------------------------------------------------------------------
/src/test/resources/artifacts/org/quartz-scheduler/quartz/2.3.0/quartz-2.3.0.jar:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/test/resources/artifacts/org/quartz-scheduler/quartz-jobs/2.3.0/quartz-jobs-2.3.0.jar:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/spring-attic/bomr/master/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/src/main/resources/META-INF/spring.factories:
--------------------------------------------------------------------------------
1 | org.springframework.boot.env.EnvironmentPostProcessor=io.spring.bomr.UserHomeBomrPropertiesEnvironmentPostProcessor
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Eclipse
2 | .classpath
3 | .factorypath
4 | .project
5 | .settings
6 | /bin/
7 |
8 | # IntelliJ IDEA
9 | .idea
10 | *.iml
11 |
12 | /build/
13 | /.gradle/
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-bin.zip
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 |
--------------------------------------------------------------------------------
/config/checkstyle/checkstyle-suppressions.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/config/checkstyle/checkstyle.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/src/test/resources/artifacts/org/quartz-scheduler/internal/index.html:
--------------------------------------------------------------------------------
1 |
2 |
302 Moved Temporarily
3 |
4 | 302 Moved Temporarily
5 |
6 | - Code: Found
7 | - Message: Resource Found
8 | - RequestId: E58ACE82DBB1ED1E
9 | - HostId: R6jZCOY1+UtVUsRIbxKCogNKwHyS1y3FS8HGW0td0qn1Aob6ZMfcOmphE2z7ogBy1IWCUEbhI08=
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/src/test/resources/repo1-maven-metadata.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | com.example
4 | core
5 |
6 | 1.0.0.RELEASE
7 | 1.0.0.RELEASE
8 |
9 | 1.0.0.RELEASE
10 |
11 | 20170928121756
12 |
13 |
14 |
--------------------------------------------------------------------------------
/src/test/resources/repo2-maven-metadata.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | com.example
4 | core
5 |
6 | 1.1.0.RELEASE
7 | 1.1.0.RELEASE
8 |
9 | 1.0.0.RELEASE
10 | 1.1.0.RELEASE
11 |
12 | 20170928121756
13 |
14 |
15 |
--------------------------------------------------------------------------------
/launch.script:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | [[ -n "$DEBUG" ]] && set -x
4 |
5 | working_directory="$(pwd)"
6 |
7 | # Follow symlinks to find the real jar
8 | cd "$(dirname "$0")" || exit 1
9 | [[ -z "$jarfile" ]] && jarfile=$(pwd)/$(basename "$0")
10 | while [[ -L "$jarfile" ]]; do
11 | jarfile=$(readlink "$jarfile")
12 | cd "$(dirname "$jarfile")" || exit 1
13 | jarfile=$(pwd)/$(basename "$jarfile")
14 | done
15 |
16 | cd "$working_directory"
17 |
18 | # Find Java
19 | if [[ -n "$JAVA_HOME" ]] && [[ -x "$JAVA_HOME/bin/java" ]]; then
20 | javaexe="$JAVA_HOME/bin/java"
21 | elif type -p java > /dev/null 2>&1; then
22 | javaexe=$(type -p java)
23 | elif [[ -x "/usr/bin/java" ]]; then
24 | javaexe="/usr/bin/java"
25 | else
26 | echo "Unable to find Java"
27 | exit 1
28 | fi
29 |
30 | arguments=(-Dsun.misc.URLClassPath.disableJarChecking=true $JAVA_OPTS -jar "$jarfile" $RUN_ARGS "$@")
31 |
32 | "$javaexe" "${arguments[@]}"
33 | exit $?
34 |
--------------------------------------------------------------------------------
/src/test/resources/spring-core-maven-metadata.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | org.springframework
4 | spring-core
5 |
6 | 5.0.0.RELEASE
7 | 5.0.0.RELEASE
8 |
9 | 4.3.0.RELEASE
10 | 4.3.1.RELEASE
11 | 4.3.2.RELEASE
12 | 4.3.3.RELEASE
13 | 4.3.4.RELEASE
14 | 4.3.5.RELEASE
15 | 4.3.6.RELEASE
16 | 4.3.7.RELEASE
17 | 4.3.8.RELEASE
18 | 4.3.9.RELEASE
19 | 4.3.10.RELEASE
20 | 4.3.11.RELEASE
21 | 5.0.0.RELEASE
22 |
23 | 20170928121756
24 |
25 |
26 |
--------------------------------------------------------------------------------
/src/main/java/io/spring/bomr/upgrade/UpgradeResolver.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017-2019 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.spring.bomr.upgrade;
18 |
19 | import java.util.Collection;
20 | import java.util.List;
21 |
22 | /**
23 | * Resolves upgrades for {@link Project Projects}.
24 | *
25 | * @author Andy Wilkinson
26 | */
27 | interface UpgradeResolver {
28 |
29 | /**
30 | * Resolves the upgrades to be applied to the given {@code projects}.
31 | * @param projects the projects
32 | * @return the upgrades
33 | */
34 | List resolveUpgrades(Collection projects);
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/io/spring/bomr/github/GitHub.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.spring.bomr.github;
18 |
19 | /**
20 | * Minimal API for interacting with GitHub.
21 | *
22 | * @author Andy Wilkinson
23 | */
24 | public interface GitHub {
25 |
26 | /**
27 | * Returns a {@link GitHubRepository} with the given {@code name} in the given
28 | * {@code organization}.
29 | * @param organization the organization
30 | * @param name the name of the repository
31 | * @return the repository
32 | */
33 | GitHubRepository getRepository(String organization, String name);
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/io/spring/bomr/upgrade/VersionResolver.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017-2019 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.spring.bomr.upgrade;
18 |
19 | import java.util.SortedSet;
20 |
21 | import io.spring.bomr.upgrade.version.DependencyVersion;
22 |
23 | /**
24 | * Resolves the available versions for a {@link Module}.
25 | *
26 | * @author Andy Wilkinson
27 | */
28 | interface VersionResolver {
29 |
30 | /**
31 | * Resolves the available versions for the given {@code module}.
32 | * @param module the module
33 | * @return the available versions
34 | */
35 | SortedSet resolveVersions(Module module);
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/src/main/java/io/spring/bomr/artifacts/ArtifactsConfiguration.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017-2018 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.spring.bomr.artifacts;
18 |
19 | import org.springframework.context.annotation.Bean;
20 | import org.springframework.context.annotation.Configuration;
21 |
22 | /**
23 | * Configuration for Bomr's artifacts support.
24 | *
25 | * @author Andy Wilkinson
26 | */
27 | @Configuration
28 | class ArtifactsConfiguration {
29 |
30 | @Bean
31 | public ArtifactsCommand artifactsCommand() {
32 | return new ArtifactsCommand();
33 | }
34 |
35 | @Bean
36 | public ArtifactsDeltaCommand artifactsDeltaCommand() {
37 | return new ArtifactsDeltaCommand();
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/src/main/java/io/spring/bomr/upgrade/Module.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.spring.bomr.upgrade;
18 |
19 | /**
20 | * A module of a {@link Project}.
21 | *
22 | * @author Andy Wilkinson
23 | */
24 | final class Module {
25 |
26 | private final String groupId;
27 |
28 | private final String artifactId;
29 |
30 | Module(String groupId, String artifactId) {
31 | this.groupId = groupId;
32 | this.artifactId = artifactId;
33 | }
34 |
35 | String getGroupId() {
36 | return this.groupId;
37 | }
38 |
39 | String getArtifactId() {
40 | return this.artifactId;
41 | }
42 |
43 | @Override
44 | public String toString() {
45 | return this.groupId + ":" + this.artifactId;
46 | }
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/src/main/java/io/spring/bomr/BomrProperties.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017-2019 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.spring.bomr;
18 |
19 | import java.io.File;
20 |
21 | import org.springframework.boot.context.properties.ConfigurationProperties;
22 |
23 | /**
24 | * General {@link ConfigurationProperties configuration properties} that are not specific
25 | * to any one command.
26 | *
27 | * @author Andy Wilkinson
28 | */
29 | @ConfigurationProperties("bomr")
30 | public class BomrProperties {
31 |
32 | /**
33 | * Location of the pom file to be analyzed by Bomr.
34 | */
35 | private File bom;
36 |
37 | public File getBom() {
38 | return this.bom;
39 | }
40 |
41 | public void setBom(File bom) {
42 | this.bom = bom;
43 | }
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/src/main/java/io/spring/bomr/github/GitHubConfiguration.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017-2019 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.spring.bomr.github;
18 |
19 | import org.springframework.boot.context.properties.EnableConfigurationProperties;
20 | import org.springframework.context.annotation.Bean;
21 | import org.springframework.context.annotation.Configuration;
22 |
23 | /**
24 | * {@link Configuration} for GitHub-related components.
25 | *
26 | * @author Andy Wilkinson
27 | */
28 | @Configuration
29 | @EnableConfigurationProperties(GitHubProperties.class)
30 | class GitHubConfiguration {
31 |
32 | @Bean
33 | public GitHub gitHub(GitHubProperties gitHubProperties) {
34 | return new StandardGitHub(gitHubProperties.getUsername(), gitHubProperties.getPassword());
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/src/main/java/io/spring/bomr/upgrade/Upgrade.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017-2019 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.spring.bomr.upgrade;
18 |
19 | import io.spring.bomr.upgrade.version.DependencyVersion;
20 | import org.eclipse.aether.version.Version;
21 |
22 | /**
23 | * An upgrade to change a {@link Project} to use a new {@link Version}.
24 | *
25 | * @author Andy Wilkinson
26 | */
27 | final class Upgrade {
28 |
29 | private final Project project;
30 |
31 | private final DependencyVersion version;
32 |
33 | Upgrade(Project project, DependencyVersion version) {
34 | this.project = project;
35 | this.version = version;
36 | }
37 |
38 | Project getProject() {
39 | return this.project;
40 | }
41 |
42 | DependencyVersion getVersion() {
43 | return this.version;
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/src/main/java/io/spring/bomr/upgrade/ProhibitedVersions.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017-2019 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.spring.bomr.upgrade;
18 |
19 | import java.util.List;
20 |
21 | import org.apache.maven.artifact.versioning.VersionRange;
22 |
23 | /**
24 | * Prohibited versions of a project.
25 | *
26 | * @author Andy Wilkinson
27 | */
28 | class ProhibitedVersions {
29 |
30 | private String project;
31 |
32 | private List versions;
33 |
34 | public String getProject() {
35 | return this.project;
36 | }
37 |
38 | public void setProject(String project) {
39 | this.project = project;
40 | }
41 |
42 | public List getVersions() {
43 | return this.versions;
44 | }
45 |
46 | public void setVersions(List versions) {
47 | this.versions = versions;
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/src/main/java/io/spring/bomr/upgrade/StringToVersionRangeConverter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017-2019 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.spring.bomr.upgrade;
18 |
19 | import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
20 | import org.apache.maven.artifact.versioning.VersionRange;
21 |
22 | import org.springframework.core.convert.converter.Converter;
23 |
24 | /**
25 | * {@link Converter} to create a {@link VersionRange} from a {@link String}.
26 | *
27 | * @author Andy Wilkinson
28 | */
29 | class StringToVersionRangeConverter implements Converter {
30 |
31 | @Override
32 | public VersionRange convert(String source) {
33 | try {
34 | return VersionRange.createFromVersionSpec(source);
35 | }
36 | catch (InvalidVersionSpecificationException ex) {
37 | throw new IllegalArgumentException(ex);
38 | }
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/src/main/java/io/spring/bomr/verify/MavenProperties.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017-2019 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.spring.bomr.verify;
18 |
19 | import java.io.File;
20 |
21 | import org.springframework.boot.context.properties.ConfigurationProperties;
22 |
23 | /**
24 | * Properties for configuring Maven.
25 | *
26 | * @author Andy Wilkinson
27 | */
28 | @ConfigurationProperties("bomr.maven")
29 | public class MavenProperties {
30 |
31 | /**
32 | * Maven's home directory.
33 | */
34 | private File home;
35 |
36 | /**
37 | * Returns the location of Maven's home directory.
38 | * @return the home directory
39 | */
40 | public File getHome() {
41 | return this.home;
42 | }
43 |
44 | /**
45 | * Sets the location of Maven's home directory.
46 | * @param home the home directory
47 | */
48 | public void setHome(File home) {
49 | this.home = home;
50 | }
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/src/main/java/io/spring/bomr/Command.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017-2019 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.spring.bomr;
18 |
19 | /**
20 | * A Bomr command.
21 | *
22 | * @author Andy Wilkinson
23 | */
24 | public interface Command extends Comparable {
25 |
26 | /**
27 | * Returns the name of the command that is used to invoke it from the command line.
28 | * @return the name of the command
29 | */
30 | String getName();
31 |
32 | /**
33 | * Returns the description of the command, shown in CLI usage messages.
34 | * @return the description of the command
35 | */
36 | String getDescription();
37 |
38 | /**
39 | * Invokes the command using the given {@code args}.
40 | * @param args the args
41 | */
42 | void invoke(String[] args);
43 |
44 | @Override
45 | default int compareTo(Command command) {
46 | return getName().compareTo(command.getName());
47 | }
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/src/main/java/io/spring/bomr/upgrade/Project.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.spring.bomr.upgrade;
18 |
19 | import java.util.ArrayList;
20 | import java.util.List;
21 |
22 | import io.spring.bomr.upgrade.BomVersions.BomVersion;
23 |
24 | /**
25 | * A project made up of one or more {@link Module Modules}.
26 | *
27 | * @author Andy Wilkinson
28 | */
29 | final class Project {
30 |
31 | private final ProjectName name;
32 |
33 | private final BomVersion version;
34 |
35 | private final List modules = new ArrayList<>();
36 |
37 | Project(ProjectName name, BomVersion version) {
38 | this.name = name;
39 | this.version = version;
40 | }
41 |
42 | ProjectName getName() {
43 | return this.name;
44 | }
45 |
46 | BomVersion getVersion() {
47 | return this.version;
48 | }
49 |
50 | List getModules() {
51 | return this.modules;
52 | }
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/src/main/java/io/spring/bomr/github/Milestone.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.spring.bomr.github;
18 |
19 | /**
20 | * A milestone in a {@link GitHubRepository GitHub repository}.
21 | *
22 | * @author Andy Wilkinson
23 | */
24 | public class Milestone {
25 |
26 | private final String name;
27 |
28 | private final int number;
29 |
30 | Milestone(String name, int number) {
31 | this.name = name;
32 | this.number = number;
33 | }
34 |
35 | /**
36 | * Returns the name of the milestone.
37 | * @return the name
38 | */
39 | public String getName() {
40 | return this.name;
41 | }
42 |
43 | /**
44 | * Returns the number of the milestone.
45 | * @return the number
46 | */
47 | public int getNumber() {
48 | return this.number;
49 | }
50 |
51 | @Override
52 | public String toString() {
53 | return this.name + " (" + this.number + ")";
54 | }
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/src/main/resources/templates/bom-dependencies.mustache:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 |
7 | {{parentGroupId}}
8 | {{parentArtifactId}}
9 | {{parentVersion}}
10 | {{parentRelativePath}}
11 |
12 |
13 | {{parentGroupId}}
14 | {{parentArtifactId}}-verification
15 | {{parentVersion}}
16 | pom
17 |
18 |
19 | {{#dependencies}}
20 |
21 | {{groupId}}
22 | {{artifactId}}
23 | {{type}}
24 | {{#classifierIfAvailable}}{{classifier}}{{/classifierIfAvailable}}
25 |
26 | {{/dependencies}}
27 |
28 |
29 |
30 | {{#repositories}}
31 |
32 | {{id}}
33 | {{url}}
34 |
35 | {{snapshotsEnabled}}
36 |
37 |
38 | {{/repositories}}
39 |
40 |
41 |
42 |
43 |
44 | kr.motd.maven
45 | os-maven-plugin
46 | 1.6.1
47 |
48 |
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/src/test/resources/artifacts/org/quartz-scheduler/quartz-jobs/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Central Repository: org/quartz-scheduler/quartz-jobs
6 |
7 |
12 |
13 |
14 |
15 |
16 | org/quartz-scheduler/quartz-jobs
17 |
18 |
19 |
20 |
21 | ../
22 | 2.2.0/ 2013-06-29 21:04 -
23 | 2.2.1/ 2013-09-25 18:48 -
24 | 2.2.2/ 2015-10-12 11:52 -
25 | 2.2.3/ 2016-04-18 18:26 -
26 | 2.3.0/ 2017-04-19 19:41 -
27 | maven-metadata.xml 2017-04-19 20:16 462
28 | maven-metadata.xml.md5 2017-04-19 20:16 32
29 | maven-metadata.xml.sha1 2017-04-19 20:16 40
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/src/main/java/io/spring/bomr/verify/ManagedDependency.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017-2018 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.spring.bomr.verify;
18 |
19 | import org.springframework.util.StringUtils;
20 |
21 | /**
22 | * Details of a dependency managed by a bom.
23 | *
24 | * @author Andy Wilkinson
25 | */
26 | class ManagedDependency {
27 |
28 | private final String groupId;
29 |
30 | private final String artifactId;
31 |
32 | private final String classifier;
33 |
34 | private final String type;
35 |
36 | ManagedDependency(String groupId, String artifactId, String classifier, String type) {
37 | this.groupId = groupId;
38 | this.artifactId = artifactId;
39 | this.classifier = classifier;
40 | this.type = StringUtils.hasText(type) ? type : "jar";
41 | }
42 |
43 | String getGroupId() {
44 | return this.groupId;
45 | }
46 |
47 | String getArtifactId() {
48 | return this.artifactId;
49 | }
50 |
51 | String getClassifier() {
52 | return this.classifier;
53 | }
54 |
55 | String getType() {
56 | return this.type;
57 | }
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/src/main/java/io/spring/bomr/github/GitHubRepository.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.spring.bomr.github;
18 |
19 | import java.util.List;
20 |
21 | /**
22 | * Minimal API for interacting with a GitHub repository.
23 | *
24 | * @author Andy Wilkinson
25 | */
26 | public interface GitHubRepository {
27 |
28 | /**
29 | * Opens a new issue with the given title. The given {@code labels} will be applied to
30 | * the issue and it will be assigned to the given {@code milestone}.
31 | * @param title the title of the issue
32 | * @param labels the labels to apply to the issue
33 | * @param milestone the milestone to assign the issue to
34 | * @return the number of the new issue
35 | */
36 | int openIssue(String title, List labels, Milestone milestone);
37 |
38 | /**
39 | * Returns the labels in the repository.
40 | * @return the labels
41 | */
42 | List getLabels();
43 |
44 | /**
45 | * Returns the milestones in the repository.
46 | * @return the milestones
47 | */
48 | List getMilestones();
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/src/test/resources/artifacts/org/quartz-scheduler/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Central Repository: org/quartz-scheduler
6 |
7 |
12 |
13 |
14 |
15 |
16 | org/quartz-scheduler
17 |
18 |
19 |
20 |
21 | ../
22 | internal/ - -
23 | quartz/ - -
24 | quartz-backward-compat/ - -
25 | quartz-commonj/ - -
26 | quartz-jboss/ - -
27 | quartz-jobs/ - -
28 | quartz-oracle/ - -
29 | quartz-parent/ - -
30 | quartz-weblogic/ - -
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/src/main/java/io/spring/bomr/artifacts/ArtifactsFinder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017-2019 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.spring.bomr.artifacts;
18 |
19 | import java.net.URI;
20 | import java.util.Set;
21 |
22 | import org.springframework.web.client.RestTemplate;
23 |
24 | /**
25 | * An {@code ArtifactsFinder} is used to find artifacts in a repository.
26 | *
27 | * @author Andy Wilkinson
28 | */
29 | interface ArtifactsFinder {
30 |
31 | URI MAVEN_CENTRAL = URI.create("https://repo1.maven.org/maven2/");
32 |
33 | static ArtifactsFinder forRepository(URI repository) {
34 | return repository.equals(MAVEN_CENTRAL) ? new MavenCentralSearchArtifactsFinder(new RestTemplate())
35 | : new MavenRepositoryArtifactsFinder(new RestTemplate(), repository);
36 | }
37 |
38 | /**
39 | * Finds the artifacts with the given {@code group} and {@code version} in the
40 | * repository.
41 | * @param group the group
42 | * @param version the version
43 | * @return the artifacts in the group with the required version
44 | */
45 | Set find(String group, String version);
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/src/main/java/io/spring/bomr/verify/VerifyProperties.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017-2019 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.spring.bomr.verify;
18 |
19 | import java.net.URI;
20 | import java.util.HashSet;
21 | import java.util.Set;
22 |
23 | import org.springframework.boot.context.properties.ConfigurationProperties;
24 |
25 | /**
26 | * {@link ConfigurationProperties Configuration properties} for bom verification.
27 | *
28 | * @author Andy Wilkinson
29 | */
30 | @ConfigurationProperties(prefix = "bomr.verify", ignoreUnknownFields = false)
31 | public class VerifyProperties {
32 |
33 | /**
34 | * Dependencies (groupId:artifactId) to be ignored when verifying the bom.
35 | */
36 | private final Set ignoredDependencies = new HashSet<>();
37 |
38 | /**
39 | * Additional repositories to use for dependency resolution when verifying the bom.
40 | */
41 | private final Set repositories = new HashSet<>();
42 |
43 | public Set getIgnoredDependencies() {
44 | return this.ignoredDependencies;
45 | }
46 |
47 | public Set getRepositories() {
48 | return this.repositories;
49 | }
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/src/main/java/io/spring/bomr/verify/VerificationConfiguration.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017-2019 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.spring.bomr.verify;
18 |
19 | import com.samskivert.mustache.Mustache.Compiler;
20 | import com.samskivert.mustache.Mustache.TemplateLoader;
21 | import io.spring.bomr.BomrProperties;
22 |
23 | import org.springframework.boot.context.properties.EnableConfigurationProperties;
24 | import org.springframework.context.annotation.Bean;
25 | import org.springframework.context.annotation.Configuration;
26 |
27 | /**
28 | * Configuration for bom verification.
29 | *
30 | * @author Andy Wilkinson
31 | */
32 | @Configuration
33 | @EnableConfigurationProperties({ MavenProperties.class, VerifyProperties.class })
34 | class VerificationConfiguration {
35 |
36 | @Bean
37 | public VerifyCommand verifyCommand(BomrProperties bomr, MavenProperties maven, VerifyProperties verify,
38 | Compiler compiler, TemplateLoader templateLoader) {
39 | return new VerifyCommand(new BomVerifier(new MavenInvoker(maven.getHome()), compiler, templateLoader),
40 | bomr.getBom(), verify.getIgnoredDependencies(), verify.getRepositories());
41 | }
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/src/main/java/io/spring/bomr/upgrade/UpgradeConfiguration.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017-2019 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.spring.bomr.upgrade;
18 |
19 | import io.spring.bomr.BomrProperties;
20 | import io.spring.bomr.github.GitHub;
21 |
22 | import org.springframework.boot.context.properties.ConfigurationPropertiesBinding;
23 | import org.springframework.boot.context.properties.EnableConfigurationProperties;
24 | import org.springframework.context.annotation.Bean;
25 | import org.springframework.context.annotation.Configuration;
26 |
27 | /**
28 | * Configuration for Bomr's upgrade support.
29 | *
30 | * @author Andy Wilkinson
31 | */
32 | @Configuration
33 | @EnableConfigurationProperties(UpgradeProperties.class)
34 | class UpgradeConfiguration {
35 |
36 | @Bean
37 | public UpgradeCommand upgradeCommand(GitHub gitHub, UpgradeProperties upgradeProperties,
38 | BomrProperties bomrProperties) {
39 | return new UpgradeCommand(gitHub, upgradeProperties, bomrProperties.getBom());
40 | }
41 |
42 | @Bean
43 | @ConfigurationPropertiesBinding
44 | public StringToVersionRangeConverter stringToVersionRangeConverter() {
45 | return new StringToVersionRangeConverter();
46 | }
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/src/main/java/io/spring/bomr/verify/Repository.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.spring.bomr.verify;
18 |
19 | import java.net.URI;
20 |
21 | /**
22 | * Representation of a repository that can be declared in a Maven pom.
23 | *
24 | * @author Andy Wilkinson
25 | */
26 | final class Repository {
27 |
28 | private final String id;
29 |
30 | private final URI url;
31 |
32 | private final boolean snapshotsEnabled;
33 |
34 | Repository(URI url) {
35 | this.id = (url.getHost() + "-" + url.getPath()).replace("/", "-");
36 | this.url = url;
37 | this.snapshotsEnabled = false;
38 | }
39 |
40 | Repository(String id, URI url, boolean snapshotsEnabled) {
41 | this.id = id;
42 | this.url = url;
43 | this.snapshotsEnabled = snapshotsEnabled;
44 | }
45 |
46 | /**
47 | * Returns the id of the repository.
48 | * @return the id
49 | */
50 | public String getId() {
51 | return this.id;
52 | }
53 |
54 | /**
55 | * Returns the URL of the repository.
56 | * @return the URL
57 | */
58 | public URI getUrl() {
59 | return this.url;
60 | }
61 |
62 | /**
63 | * Whether snapshots are enabled for the repository.
64 | * @return {@code true} if snapshots are enabled, otherwise {@code false}
65 | */
66 | public boolean isSnapshotsEnabled() {
67 | return this.snapshotsEnabled;
68 | }
69 |
70 | }
71 |
--------------------------------------------------------------------------------
/src/main/java/io/spring/bomr/upgrade/version/UnstructuredDependencyVersion.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017-2019 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.spring.bomr.upgrade.version;
18 |
19 | import org.apache.maven.artifact.versioning.ComparableVersion;
20 |
21 | /**
22 | * A {@link DependencyVersion} with no structure such that version comparisons are not
23 | * possible.
24 | *
25 | * @author Andy Wilkinson
26 | */
27 | public class UnstructuredDependencyVersion extends AbstractDependencyVersion implements DependencyVersion {
28 |
29 | private final String version;
30 |
31 | public UnstructuredDependencyVersion(String version) {
32 | super(new ComparableVersion(version));
33 | this.version = version;
34 | }
35 |
36 | @Override
37 | public boolean isNewerThan(DependencyVersion other) {
38 | return this.compareTo(other) > 0;
39 | }
40 |
41 | @Override
42 | public boolean isSameMajorAndNewerThan(DependencyVersion other) {
43 | return this.compareTo(other) > 0;
44 | }
45 |
46 | @Override
47 | public boolean isSameMinorAndNewerThan(DependencyVersion other) {
48 | return this.compareTo(other) > 0;
49 | }
50 |
51 | @Override
52 | public String toString() {
53 | return this.version;
54 | }
55 |
56 | static UnstructuredDependencyVersion parse(String version) {
57 | return new UnstructuredDependencyVersion(version);
58 | }
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/src/test/resources/artifacts/org/quartz-scheduler/quartz-commonj/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Central Repository: org/quartz-scheduler/quartz-commonj
6 |
7 |
12 |
13 |
14 |
15 |
16 | org/quartz-scheduler/quartz-commonj
17 |
18 |
19 |
20 |
21 | ../
22 | 1.8.6/ 2012-01-12 21:44 -
23 | 2.1.1/ 2011-11-14 20:22 -
24 | 2.1.2/ 2011-12-20 13:57 -
25 | 2.1.3/ 2012-01-30 19:31 -
26 | 2.1.4/ 2012-04-17 19:23 -
27 | 2.1.5/ 2012-04-27 14:51 -
28 | 2.1.6/ 2013-02-22 21:19 -
29 | 2.1.7/ 2013-03-05 15:26 -
30 | maven-metadata.xml 2013-03-05 15:39 558
31 | maven-metadata.xml.md5 2013-03-05 15:39 32
32 | maven-metadata.xml.sha1 2013-03-05 15:39 40
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/src/main/java/io/spring/bomr/upgrade/version/LeadingZeroesDependencyVersion.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017-2019 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.spring.bomr.upgrade.version;
18 |
19 | import java.util.regex.Matcher;
20 | import java.util.regex.Pattern;
21 |
22 | import org.apache.maven.artifact.versioning.ArtifactVersion;
23 | import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
24 |
25 | /**
26 | * A {@link DependencyVersion} that tolerates leading zeroes.
27 | *
28 | * @author Andy Wilkinson
29 | */
30 | public class LeadingZeroesDependencyVersion extends ArtifactVersionDependencyVersion {
31 |
32 | private static final Pattern PATTERN = Pattern.compile("0*([0-9]+)\\.0*([0-9]+)\\.0*([0-9]+)");
33 |
34 | private final String original;
35 |
36 | public LeadingZeroesDependencyVersion(ArtifactVersion artifactVersion, String original) {
37 | super(artifactVersion);
38 | this.original = original;
39 | }
40 |
41 | @Override
42 | public String toString() {
43 | return this.original;
44 | }
45 |
46 | static LeadingZeroesDependencyVersion parse(String input) {
47 | Matcher matcher = PATTERN.matcher(input);
48 | if (!matcher.matches()) {
49 | return null;
50 | }
51 | ArtifactVersion artifactVersion = new DefaultArtifactVersion(
52 | matcher.group(1) + matcher.group(2) + matcher.group(3));
53 | return new LeadingZeroesDependencyVersion(artifactVersion, input);
54 | }
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/src/main/java/io/spring/bomr/github/GitHubProperties.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017-2019 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.spring.bomr.github;
18 |
19 | import org.springframework.boot.context.properties.ConfigurationProperties;
20 |
21 | /**
22 | * Properties for configuring access to GitHub.
23 | *
24 | * @author Andy Wilkinson
25 | */
26 | @ConfigurationProperties("bomr.github")
27 | class GitHubProperties {
28 |
29 | /**
30 | * Username for authentication with GitHub.
31 | */
32 | private String username;
33 |
34 | /**
35 | * Password for authentication with GitHub.
36 | */
37 | private String password;
38 |
39 | /**
40 | * Returns the username used to authenticate with GitHub.
41 | * @return the username
42 | */
43 | public String getUsername() {
44 | return this.username;
45 | }
46 |
47 | /**
48 | * Sets the username used to authenticate with GitHub.
49 | * @param username the username
50 | */
51 | public void setUsername(String username) {
52 | this.username = username;
53 | }
54 |
55 | /**
56 | * Returns the password used to authenticate with GitHub.
57 | * @return the passwrd
58 | */
59 | public String getPassword() {
60 | return this.password;
61 | }
62 |
63 | /**
64 | * Sets the password used to authenticate with GitHub.
65 | * @param password the password
66 | */
67 | public void setPassword(String password) {
68 | this.password = password;
69 | }
70 |
71 | }
72 |
--------------------------------------------------------------------------------
/src/test/java/io/spring/bomr/upgrade/version/NumericQualifierDependencyVersionTests.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017-2019 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.spring.bomr.upgrade.version;
18 |
19 | import org.junit.Test;
20 |
21 | import static org.assertj.core.api.Assertions.assertThat;
22 |
23 | /**
24 | * Tests for {@link NumericQualifierDependencyVersion}.
25 | *
26 | * @author Andy Wilkinson
27 | */
28 | public class NumericQualifierDependencyVersionTests {
29 |
30 | @Test
31 | public void isNewerThanOnVersionWithNumericQualifierWhenInputHasNoQualifierShouldReturnTrue() {
32 | assertThat(version("2.9.9.20190806").isNewerThan(DependencyVersion.parse("2.9.9"))).isTrue();
33 | }
34 |
35 | @Test
36 | public void isNewerThanOnVersionWithNumericQualifierWhenInputHasOlderQualifierShouldReturnTrue() {
37 | assertThat(version("2.9.9.20190806").isNewerThan(version("2.9.9.20190805"))).isTrue();
38 | }
39 |
40 | @Test
41 | public void isNewerThanOnVersionWithNumericQualifierWhenInputHasNewerQualifierShouldReturnFalse() {
42 | assertThat(version("2.9.9.20190806").isNewerThan(version("2.9.9.20190807"))).isFalse();
43 | }
44 |
45 | @Test
46 | public void isNewerThanOnVersionWithNumericQualifierWhenInputHasSameQualifierShouldReturnFalse() {
47 | assertThat(version("2.9.9.20190806").isNewerThan(version("2.9.9.20190806"))).isFalse();
48 | }
49 |
50 | private NumericQualifierDependencyVersion version(String version) {
51 | return NumericQualifierDependencyVersion.parse(version);
52 | }
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/src/test/java/io/spring/bomr/upgrade/version/DependencyVersionTests.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017-2019 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.spring.bomr.upgrade.version;
18 |
19 | import org.junit.Test;
20 |
21 | import static org.assertj.core.api.Assertions.assertThat;
22 |
23 | /**
24 | * Tests for {@link DependencyVersion}.
25 | *
26 | * @author Andy Wilkinson
27 | */
28 | public class DependencyVersionTests {
29 |
30 | @Test
31 | public void parseWhenValidMavenVersionShouldReturnArtifactVersionDependencyVersion() {
32 | assertThat(DependencyVersion.parse("1.2.3.Final")).isInstanceOf(ArtifactVersionDependencyVersion.class);
33 | }
34 |
35 | @Test
36 | public void parseWhenReleaseTrainShouldReturnReleaseTrainDependencyVersion() {
37 | assertThat(DependencyVersion.parse("Ingalls-SR5")).isInstanceOf(ReleaseTrainDependencyVersion.class);
38 | }
39 |
40 | @Test
41 | public void parseWhenMavenLikeVersionWithNumericQualifieShouldReturnNumericQualifierDependencyVersion() {
42 | assertThat(DependencyVersion.parse("1.2.3.4")).isInstanceOf(NumericQualifierDependencyVersion.class);
43 | }
44 |
45 | @Test
46 | public void parseWhenVersionWithLeadingZeroesShouldReturnLeadingZeroesDependencyVersion() {
47 | assertThat(DependencyVersion.parse("1.4.01")).isInstanceOf(LeadingZeroesDependencyVersion.class);
48 | }
49 |
50 | @Test
51 | public void parseWhenVersionWithCombinedPatchAndQualifierShouldReturnCombinedPatchAndQualifierDependencyVersion() {
52 | assertThat(DependencyVersion.parse("4.0.0M4")).isInstanceOf(CombinedPatchAndQualifierDependencyVersion.class);
53 | }
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/src/main/java/io/spring/bomr/upgrade/version/NumericQualifierDependencyVersion.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017-2019 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.spring.bomr.upgrade.version;
18 |
19 | import org.apache.maven.artifact.versioning.ArtifactVersion;
20 | import org.apache.maven.artifact.versioning.ComparableVersion;
21 | import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
22 |
23 | /**
24 | * A fallback {@link DependencyVersion} to handle versions with four components that
25 | * cannot be handled by {@link ArtifactVersion} because the fourth component is numeric.
26 | *
27 | * @author Andy Wilkinson
28 | */
29 | final class NumericQualifierDependencyVersion extends ArtifactVersionDependencyVersion {
30 |
31 | private final String original;
32 |
33 | private NumericQualifierDependencyVersion(ArtifactVersion artifactVersion, String original) {
34 | super(artifactVersion, new ComparableVersion(original));
35 | this.original = original;
36 | }
37 |
38 | @Override
39 | public String toString() {
40 | return this.original;
41 | }
42 |
43 | static NumericQualifierDependencyVersion parse(String input) {
44 | String[] components = input.split("\\.");
45 | if (components.length == 4) {
46 | ArtifactVersion artifactVersion = new DefaultArtifactVersion(
47 | components[0] + "." + components[1] + "." + components[2]);
48 | if (artifactVersion.getQualifier() != null && artifactVersion.getQualifier().equals(input)) {
49 | return null;
50 | }
51 | return new NumericQualifierDependencyVersion(artifactVersion, input);
52 | }
53 | return null;
54 | }
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/src/main/java/io/spring/bomr/upgrade/ProjectName.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017-2019 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.spring.bomr.upgrade;
18 |
19 | import io.spring.bomr.upgrade.BomVersions.BomVersion;
20 |
21 | /**
22 | * The name of a {@link Project}.
23 | *
24 | * @author Andy Wilkinson
25 | */
26 | final class ProjectName {
27 |
28 | private final String name;
29 |
30 | private final String rawName;
31 |
32 | ProjectName(BomVersion version) {
33 | StringBuilder nameBuilder = new StringBuilder();
34 | String name = version.getProperty();
35 | if (name.endsWith(".version")) {
36 | name = name.substring(0, name.length() - ".version".length());
37 | }
38 | this.rawName = name;
39 | for (int i = 0; i < name.length(); i++) {
40 | char c = name.charAt(i);
41 | if (i == 0 || name.charAt(i - 1) == '-') {
42 | c = Character.toUpperCase(c);
43 | }
44 | if (c == '-') {
45 | c = ' ';
46 | }
47 | nameBuilder.append(c);
48 | }
49 | this.name = nameBuilder.toString();
50 | }
51 |
52 | String getRawName() {
53 | return this.rawName;
54 | }
55 |
56 | @Override
57 | public boolean equals(Object obj) {
58 | if (this == obj) {
59 | return true;
60 | }
61 | if (obj == null) {
62 | return false;
63 | }
64 | if (getClass() != obj.getClass()) {
65 | return false;
66 | }
67 | ProjectName other = (ProjectName) obj;
68 | return this.name.equals(other.name);
69 | }
70 |
71 | @Override
72 | public int hashCode() {
73 | return this.name.hashCode();
74 | }
75 |
76 | @Override
77 | public String toString() {
78 | return this.name;
79 | }
80 |
81 | }
82 |
--------------------------------------------------------------------------------
/src/main/java/io/spring/bomr/Commands.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.spring.bomr;
18 |
19 | import java.io.PrintWriter;
20 | import java.io.StringWriter;
21 | import java.util.HashMap;
22 | import java.util.List;
23 | import java.util.Map;
24 |
25 | import org.springframework.stereotype.Component;
26 |
27 | /**
28 | * The available {@link Command Commands}.
29 | *
30 | * @author Andy Wilkinson
31 | */
32 | @Component
33 | class Commands {
34 |
35 | private final Map commands = new HashMap<>();
36 |
37 | Commands(List commands) {
38 | commands.forEach((command) -> this.commands.put(command.getName(), command));
39 | }
40 |
41 | Command get(String name) {
42 | return this.commands.get(name);
43 | }
44 |
45 | String describe() {
46 | int maxLength = this.commands.keySet().stream().map(String::length).max((i1, i2) -> i1.compareTo(i2)).get();
47 | StringWriter description = new StringWriter();
48 | PrintWriter printer = new PrintWriter(description);
49 | this.commands.values().stream().sorted()
50 | .forEach((command) -> printer.println(describeCommand(command, maxLength + 4)));
51 | return description.toString();
52 | }
53 |
54 | private String describeCommand(Command command, int length) {
55 | return " " + rightPad(command.getName(), length) + command.getDescription();
56 | }
57 |
58 | private static String rightPad(String input, int length) {
59 | StringBuffer buffer = new StringBuffer(input);
60 | while (buffer.length() < length) {
61 | buffer.append(" ");
62 | }
63 | return buffer.toString();
64 | }
65 |
66 | }
67 |
--------------------------------------------------------------------------------
/src/main/java/io/spring/bomr/upgrade/version/CombinedPatchAndQualifierDependencyVersion.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017-2019 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.spring.bomr.upgrade.version;
18 |
19 | import java.util.regex.Matcher;
20 | import java.util.regex.Pattern;
21 |
22 | import org.apache.maven.artifact.versioning.ArtifactVersion;
23 | import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
24 |
25 | /**
26 | * A {@link DependencyVersion} where the patch and qualifier are not separated.
27 | *
28 | * @author Andy Wilkinson
29 | */
30 | public class CombinedPatchAndQualifierDependencyVersion extends ArtifactVersionDependencyVersion {
31 |
32 | private static final Pattern PATTERN = Pattern.compile("([0-9]+\\.[0-9]+\\.[0-9]+)([A-Za-z][A-Za-z0-9]+)");
33 |
34 | private final String original;
35 |
36 | public CombinedPatchAndQualifierDependencyVersion(ArtifactVersion artifactVersion, String original) {
37 | super(artifactVersion);
38 | this.original = original;
39 | }
40 |
41 | @Override
42 | public String toString() {
43 | return this.original;
44 | }
45 |
46 | static CombinedPatchAndQualifierDependencyVersion parse(String version) {
47 | Matcher matcher = PATTERN.matcher(version);
48 | if (!matcher.matches()) {
49 | return null;
50 | }
51 | ArtifactVersion artifactVersion = new DefaultArtifactVersion(matcher.group(1) + "." + matcher.group(2));
52 | if (artifactVersion.getQualifier() != null && artifactVersion.getQualifier().equals(version)) {
53 | return null;
54 | }
55 | return new CombinedPatchAndQualifierDependencyVersion(artifactVersion, version);
56 | }
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/src/main/java/io/spring/bomr/artifacts/MavenCentralSearchArtifactsFinder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017-2019 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.spring.bomr.artifacts;
18 |
19 | import java.util.ArrayList;
20 | import java.util.List;
21 | import java.util.Set;
22 | import java.util.TreeSet;
23 |
24 | import com.jayway.jsonpath.DocumentContext;
25 | import com.jayway.jsonpath.JsonPath;
26 |
27 | import org.springframework.web.client.RestOperations;
28 |
29 | /**
30 | * An {@link ArtifactsFinder} for Maven Central. Finds artifacts by querying Maven Central
31 | * Search.
32 | *
33 | * @author Andy Wilkinson
34 | */
35 | class MavenCentralSearchArtifactsFinder implements ArtifactsFinder {
36 |
37 | private static final int PAGE_SIZE = 20;
38 |
39 | private static final String URI_TEMPLATE = "https://search.maven.org/solrsearch/select?q=g:{group}+AND+v:{version}&rows={pageSize}&start={start}";
40 |
41 | private final RestOperations rest;
42 |
43 | MavenCentralSearchArtifactsFinder(RestOperations rest) {
44 | this.rest = rest;
45 | }
46 |
47 | @Override
48 | public Set find(String group, String version) {
49 | List artifacts = new ArrayList<>();
50 | int total;
51 | int start = 0;
52 | do {
53 | String result = this.rest.getForObject(URI_TEMPLATE, String.class, group, version, PAGE_SIZE, start);
54 | DocumentContext json = JsonPath.parse(result);
55 | artifacts.addAll(json.read("$.response.docs.[?('.jar' in @.ec)].a"));
56 | total = json.read("$.response.numFound");
57 | start += PAGE_SIZE;
58 | }
59 | while (start < total);
60 | return new TreeSet(artifacts);
61 | }
62 |
63 | }
64 |
--------------------------------------------------------------------------------
/src/main/java/io/spring/bomr/upgrade/version/AbstractDependencyVersion.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017-2019 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.spring.bomr.upgrade.version;
18 |
19 | import org.apache.maven.artifact.versioning.ComparableVersion;
20 |
21 | /**
22 | * Base class for {@link DependencyVersion} implementations.
23 | *
24 | * @author Andy Wilkinson
25 | */
26 | abstract class AbstractDependencyVersion implements DependencyVersion {
27 |
28 | private final ComparableVersion comparableVersion;
29 |
30 | protected AbstractDependencyVersion(ComparableVersion comparableVersion) {
31 | this.comparableVersion = comparableVersion;
32 | }
33 |
34 | @Override
35 | public int compareTo(DependencyVersion other) {
36 | ComparableVersion otherComparable = (other instanceof AbstractDependencyVersion)
37 | ? ((AbstractDependencyVersion) other).comparableVersion : new ComparableVersion(other.toString());
38 | return this.comparableVersion.compareTo(otherComparable);
39 | }
40 |
41 | @Override
42 | public boolean equals(Object obj) {
43 | if (this == obj) {
44 | return true;
45 | }
46 | if (obj == null) {
47 | return false;
48 | }
49 | if (getClass() != obj.getClass()) {
50 | return false;
51 | }
52 | AbstractDependencyVersion other = (AbstractDependencyVersion) obj;
53 | if (!this.comparableVersion.equals(other.comparableVersion)) {
54 | return false;
55 | }
56 | return true;
57 | }
58 |
59 | @Override
60 | public int hashCode() {
61 | return this.comparableVersion.hashCode();
62 | }
63 |
64 | @Override
65 | public String toString() {
66 | return this.comparableVersion.toString();
67 | }
68 |
69 | }
70 |
--------------------------------------------------------------------------------
/src/main/java/io/spring/bomr/artifacts/ArtifactsCommand.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017-2019 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.spring.bomr.artifacts;
18 |
19 | import java.util.Set;
20 |
21 | import io.spring.bomr.Command;
22 |
23 | import org.springframework.util.StringUtils;
24 |
25 | /**
26 | * A command to list all of the artifacts that are available with a particular group id
27 | * and version.
28 | *
29 | * @author Andy Wilkinson
30 | */
31 | class ArtifactsCommand implements Command {
32 |
33 | @Override
34 | public String getName() {
35 | return "artifacts";
36 | }
37 |
38 | @Override
39 | public String getDescription() {
40 | return "Lists the artifacts in a group with a matching version";
41 | }
42 |
43 | @Override
44 | public void invoke(String[] args) {
45 | ArtifactsCommandArguments arguments = ArtifactsCommandArguments.parse(args);
46 | Set artifacts = ArtifactsFinder.forRepository(arguments.getRepository()).find(arguments.getGroup(),
47 | arguments.getVersion());
48 | artifacts.forEach((artifact) -> {
49 | System.out.println("");
50 | System.out.println("\t" + arguments.getGroup() + "");
51 | System.out.println("\t" + artifact + "");
52 | System.out.println("\t" + determineVersion(arguments) + "");
53 | System.out.println("");
54 | });
55 | }
56 |
57 | private String determineVersion(ArtifactsCommandArguments arguments) {
58 | if (StringUtils.hasText(arguments.getVersionProperty())) {
59 | return "${" + arguments.getVersionProperty() + "}";
60 | }
61 | return arguments.getVersion();
62 | }
63 |
64 | }
65 |
--------------------------------------------------------------------------------
/src/main/java/io/spring/bomr/UserHomeBomrPropertiesEnvironmentPostProcessor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017-2019 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.spring.bomr;
18 |
19 | import java.io.File;
20 | import java.io.FileReader;
21 | import java.io.IOException;
22 | import java.util.Properties;
23 |
24 | import org.apache.commons.logging.Log;
25 | import org.apache.commons.logging.LogFactory;
26 |
27 | import org.springframework.boot.SpringApplication;
28 | import org.springframework.boot.env.EnvironmentPostProcessor;
29 | import org.springframework.core.env.ConfigurableEnvironment;
30 | import org.springframework.core.env.PropertiesPropertySource;
31 |
32 | /**
33 | * {@link EnvironmentPostProcessor} that loads a {@code .bomr.properties} file from the
34 | * user's home directory.
35 | *
36 | * @author Andy Wilkinson
37 | */
38 | final class UserHomeBomrPropertiesEnvironmentPostProcessor implements EnvironmentPostProcessor {
39 |
40 | private Log logger = LogFactory.getLog(UserHomeBomrPropertiesEnvironmentPostProcessor.class);
41 |
42 | @Override
43 | public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) {
44 | File bomrPropertiesFile = new File(System.getProperty("user.home"), ".bomr.properties");
45 | if (bomrPropertiesFile.exists()) {
46 | Properties bomrProperties = new Properties();
47 | try (FileReader reader = new FileReader(bomrPropertiesFile)) {
48 | bomrProperties.load(reader);
49 | }
50 | catch (IOException ex) {
51 | this.logger.warn("Failed to load '" + bomrPropertiesFile.getAbsolutePath() + "'", ex);
52 | }
53 | environment.getPropertySources().addLast(new PropertiesPropertySource("bomr", bomrProperties));
54 | }
55 | }
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/src/main/java/io/spring/bomr/upgrade/UpgradePolicy.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017-2019 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.spring.bomr.upgrade;
18 |
19 | import java.util.function.BiPredicate;
20 |
21 | import io.spring.bomr.upgrade.version.DependencyVersion;
22 |
23 | /**
24 | * Policies used to decide which versions are considered as possible upgrades.
25 | *
26 | * @author Andy Wilkinson
27 | */
28 | public enum UpgradePolicy implements BiPredicate {
29 |
30 | /**
31 | * All versions more recent than the current version will be suggested as possible
32 | * upgrades.
33 | */
34 | ANY((candidate, current) -> current.compareTo(candidate) < 0),
35 |
36 | /**
37 | * New minor versions of the current major version will be suggested as possible
38 | * upgrades. For example, if the current version is 1.2.3, all 1.x.y versions after
39 | * 1.2.3 will be suggested. 2.x versions will not be offered.
40 | */
41 | SAME_MAJOR_VERSION(DependencyVersion::isSameMajorAndNewerThan),
42 |
43 | /**
44 | * New patch versions of the current minor version will be offered as possible
45 | * upgrades. For example, if the current version is 1.2.3, all 1.2.x versions after
46 | * 1.2.3 will be suggested. 1.x versions will not be offered.
47 | */
48 | SAME_MINOR_VERSION(DependencyVersion::isSameMinorAndNewerThan);
49 |
50 | private BiPredicate delegate;
51 |
52 | UpgradePolicy(BiPredicate delegate) {
53 | this.delegate = delegate;
54 | }
55 |
56 | @Override
57 | public boolean test(DependencyVersion candidate, DependencyVersion current) {
58 | return this.delegate.test(candidate, current);
59 | }
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/src/test/resources/artifacts/org/quartz-scheduler/quartz-backward-compat/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Central Repository: org/quartz-scheduler/quartz-backward-compat
6 |
7 |
12 |
13 |
14 |
15 |
16 | org/quartz-scheduler/quartz-backward-compat
17 |
18 |
19 |
20 |
21 | ../
22 | 2.0.0/ 2011-03-28 20:34 -
23 | 2.0.1/ 2011-04-14 03:39 -
24 | 2.0.2/ 2011-07-07 18:47 -
25 | 2.1.0/ 2011-09-22 21:48 -
26 | 2.1.1/ 2011-11-14 20:21 -
27 | 2.1.2/ 2011-12-20 13:56 -
28 | 2.1.3/ 2012-01-30 19:31 -
29 | 2.1.4/ 2012-04-17 19:23 -
30 | 2.1.5/ 2012-04-27 14:51 -
31 | 2.1.6/ 2013-02-22 21:20 -
32 | 2.1.7/ 2013-03-05 15:26 -
33 | maven-metadata.xml 2013-03-05 15:39 659
34 | maven-metadata.xml.md5 2013-03-05 15:39 32
35 | maven-metadata.xml.sha1 2013-03-05 15:39 40
36 |
37 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/src/main/java/io/spring/bomr/upgrade/UpgradeCommandArguments.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.spring.bomr.upgrade;
18 |
19 | import java.io.IOException;
20 |
21 | import joptsimple.ArgumentAcceptingOptionSpec;
22 | import joptsimple.BuiltinHelpFormatter;
23 | import joptsimple.OptionParser;
24 | import joptsimple.OptionSet;
25 |
26 | /**
27 | * Command line arguments for the {@link UpgradeCommand}.
28 | *
29 | * @author Andy Wilkinson
30 | */
31 | final class UpgradeCommandArguments {
32 |
33 | private final String milestone;
34 |
35 | private UpgradeCommandArguments(String milestone) {
36 | this.milestone = milestone;
37 | }
38 |
39 | static UpgradeCommandArguments parse(String[] args) {
40 | OptionParser optionParser = new OptionParser();
41 | optionParser.formatHelpWith(new BuiltinHelpFormatter(120, 2));
42 | ArgumentAcceptingOptionSpec milestoneSpec = optionParser
43 | .accepts("milestone", "Milestone to which upgrade issues are assigned").withRequiredArg()
44 | .ofType(String.class);
45 | try {
46 | OptionSet parsed = optionParser.parse(args);
47 | if (parsed.nonOptionArguments().size() != 0) {
48 | showUsageAndExit(optionParser);
49 | }
50 | return new UpgradeCommandArguments(parsed.valueOf(milestoneSpec));
51 | }
52 | catch (Exception ex) {
53 | showUsageAndExit(optionParser);
54 | }
55 | return null;
56 | }
57 |
58 | private static void showUsageAndExit(OptionParser optionParser) {
59 | System.err.println("Usage: bomr upgrade []");
60 | System.err.println();
61 | try {
62 | optionParser.printHelpOn(System.err);
63 | }
64 | catch (IOException ex) {
65 | // Continue
66 | }
67 | System.err.println();
68 | System.exit(-1);
69 | }
70 |
71 | String getMilestone() {
72 | return this.milestone;
73 | }
74 |
75 | }
76 |
--------------------------------------------------------------------------------
/src/main/java/io/spring/bomr/BomrApplication.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017-2019 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.spring.bomr;
18 |
19 | import java.util.Arrays;
20 |
21 | import org.springframework.boot.Banner.Mode;
22 | import org.springframework.boot.autoconfigure.SpringBootApplication;
23 | import org.springframework.boot.builder.SpringApplicationBuilder;
24 | import org.springframework.boot.context.properties.EnableConfigurationProperties;
25 | import org.springframework.context.ConfigurableApplicationContext;
26 |
27 | /**
28 | * Main entry point for Bomr.
29 | *
30 | * @author Andy Wilkinson
31 | */
32 | @SpringBootApplication
33 | @EnableConfigurationProperties(BomrProperties.class)
34 | public class BomrApplication {
35 |
36 | public static void main(String[] args) {
37 | ConfigurableApplicationContext context = new SpringApplicationBuilder(BomrApplication.class)
38 | .properties("logging.level.root=warn", "spring.config.location=file:.bomr/", "spring.config.name=bomr")
39 | .bannerMode(Mode.OFF).run(args);
40 | Commands commands = context.getBean(Commands.class);
41 | if (args.length == 0) {
42 | displayUsage();
43 | System.err.println();
44 | displayCommandList(commands);
45 | System.exit(-1);
46 | }
47 | Command command = commands.get(args[0]);
48 | if (command == null) {
49 | System.err.println("bomr: '" + args[0] + "' is not a bomr command");
50 | System.err.println();
51 | displayCommandList(commands);
52 | System.exit(-1);
53 | }
54 | else {
55 | command.invoke(Arrays.copyOfRange(args, 1, args.length));
56 | }
57 | }
58 |
59 | private static void displayUsage() {
60 | System.err.println("Usage: bomr []");
61 | }
62 |
63 | private static void displayCommandList(Commands commands) {
64 | System.err.println("Commands:");
65 | System.err.println();
66 | System.err.println(commands.describe());
67 | System.err.println();
68 | }
69 |
70 | }
71 |
--------------------------------------------------------------------------------
/src/main/java/io/spring/bomr/github/StandardGitHubRepository.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.spring.bomr.github;
18 |
19 | import java.util.HashMap;
20 | import java.util.List;
21 | import java.util.Map;
22 | import java.util.function.Function;
23 | import java.util.stream.Collectors;
24 |
25 | import org.springframework.http.ResponseEntity;
26 | import org.springframework.web.client.RestTemplate;
27 |
28 | /**
29 | * Standard implementation of {@link GitHubRepository}.
30 | *
31 | * @author Andy Wilkinson
32 | */
33 | final class StandardGitHubRepository implements GitHubRepository {
34 |
35 | private final RestTemplate rest;
36 |
37 | StandardGitHubRepository(RestTemplate restTemplate) {
38 | this.rest = restTemplate;
39 | }
40 |
41 | @Override
42 | @SuppressWarnings("rawtypes")
43 | public int openIssue(String title, List labels, Milestone milestone) {
44 | Map body = new HashMap<>();
45 | body.put("title", title);
46 | if (milestone != null) {
47 | body.put("milestone", milestone.getNumber());
48 | }
49 | if (!labels.isEmpty()) {
50 | body.put("labels", labels);
51 | }
52 | ResponseEntity