Skip to content

Commit 63521dc

Browse files
authored
Fixed maven repository condition (spring-projects-experimental#243)
1 parent 81dced9 commit 63521dc

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

components/sbm-core/src/main/java/org/springframework/sbm/build/migration/conditions/NoRepositoryExistsCondition.java

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,8 @@ public String getDescription() {
3939
public boolean evaluate(ProjectContext context) {
4040
// if name is set and repo
4141

42-
return context.getBuildFile().getRepositories().stream()
43-
.anyMatch(r -> !urlsAreEqual(r) || (!snapshotsSettingsEqual(r) || !releaseSettingsEqual(r)));
44-
}
45-
46-
private boolean releaseSettingsEqual(RepositoryDefinition r) {
47-
return (releasesEnabled == null && r.getReleasesEnabled() == null) || (releasesEnabled != null && r.getReleasesEnabled() != null && (releasesEnabled.equals(r.getReleasesEnabled())));
48-
}
49-
50-
private boolean snapshotsSettingsEqual(RepositoryDefinition r) {
51-
return (snapshotsEnabled == null && r.getSnapshotsEnabled() == null) || (snapshotsEnabled != null && r.getSnapshotsEnabled() != null && snapshotsEnabled.equals(r.getSnapshotsEnabled()));
42+
return !context.getBuildFile().getRepositories().stream()
43+
.anyMatch(this::urlsAreEqual);
5244
}
5345

5446
private boolean urlsAreEqual(RepositoryDefinition r) {

components/sbm-core/src/test/java/org/springframework/sbm/build/migration/conditions/NoRepositoryExistsConditionTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ void repositoryWithSameUrlAndSnapshotsFalseAndReleasesNotSet() {
8686
noRepositoryExistsCondition.setUrl("https://repo.spring.io/milestone");
8787
boolean noRepositoryExists = noRepositoryExistsCondition.evaluate(context);
8888

89-
assertThat(noRepositoryExists).isTrue();
89+
assertThat(noRepositoryExists).isFalse();
9090
}
9191

9292
@Test
@@ -185,7 +185,7 @@ void repositoryWithSameUrlAndSnapshotsNotSetAndReleasesFalse() {
185185
noRepositoryExistsCondition.setUrl("https://repo.spring.io/milestone");
186186
boolean noRepositoryExists = noRepositoryExistsCondition.evaluate(context);
187187

188-
assertThat(noRepositoryExists).isTrue();
188+
assertThat(noRepositoryExists).isFalse();
189189
}
190190

191191
@Test

0 commit comments

Comments
 (0)