#33 - Projects can now have an explicit full name.
Project has a withFullName(…) to be able to define it manually. Projects makes use of that to explicitly define the name for Apache backed ones. Introduced a skipTests property to make explicit, which projects should not have their test run during a build. Introduced overloads to allow the optional lookup of a Project by name.
This commit is contained in:
@@ -93,7 +93,7 @@ class ReleaseCommands extends TimedCommand {
|
||||
|
||||
deployment.verifyAuthentication();
|
||||
|
||||
Project project = Projects.byName(projectName);
|
||||
Project project = Projects.requiredByName(projectName);
|
||||
ModuleIteration module = iteration.getModule(project);
|
||||
|
||||
DeploymentInformation information = build.performRelease(module);
|
||||
|
||||
@@ -15,9 +15,12 @@
|
||||
*/
|
||||
package org.springframework.data.release.model;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.ToString;
|
||||
import lombok.experimental.Wither;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
@@ -29,30 +32,40 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
@ToString
|
||||
@EqualsAndHashCode
|
||||
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public class Project implements Comparable<Project> {
|
||||
|
||||
private final @Getter ProjectKey key;
|
||||
private final @Getter String name;
|
||||
private final @Wither String fullName;
|
||||
private final @Getter List<Project> dependencies;
|
||||
private final @Getter Tracker tracker;
|
||||
private final @Getter ArtifactCoordinates additionalArtifacts;
|
||||
private final @Wither boolean skipTests;
|
||||
|
||||
Project(String key, String name, List<Project> dependencies) {
|
||||
this(key, name, Tracker.JIRA, dependencies, ArtifactCoordinates.NONE);
|
||||
this(key, name, null, Tracker.JIRA, dependencies, ArtifactCoordinates.NONE);
|
||||
}
|
||||
|
||||
Project(String key, String name, List<Project> dependencies, ArtifactCoordinates additionalArtifacts) {
|
||||
this(key, name, Tracker.JIRA, dependencies, additionalArtifacts);
|
||||
this(key, name, null, Tracker.JIRA, dependencies, additionalArtifacts);
|
||||
}
|
||||
|
||||
Project(String key, String name, Tracker tracker, List<Project> dependencies,
|
||||
ArtifactCoordinates additionalArtifacts) {
|
||||
this(key, name, null, tracker, dependencies, additionalArtifacts);
|
||||
}
|
||||
|
||||
private Project(String key, String name, String fullName, Tracker tracker, List<Project> dependencies,
|
||||
ArtifactCoordinates additionalArtifacts) {
|
||||
|
||||
this.key = new ProjectKey(key);
|
||||
this.name = name;
|
||||
this.fullName = fullName;
|
||||
this.dependencies = dependencies;
|
||||
this.tracker = tracker;
|
||||
this.additionalArtifacts = additionalArtifacts;
|
||||
this.skipTests = false;
|
||||
}
|
||||
|
||||
public boolean uses(Tracker tracker) {
|
||||
@@ -60,7 +73,7 @@ public class Project implements Comparable<Project> {
|
||||
}
|
||||
|
||||
public String getFullName() {
|
||||
return "Spring Data ".concat(name);
|
||||
return fullName != null ? fullName : "Spring Data ".concat(name);
|
||||
}
|
||||
|
||||
public String getFolderName() {
|
||||
@@ -88,6 +101,10 @@ public class Project implements Comparable<Project> {
|
||||
return dependencies.stream().anyMatch(dependency -> dependency.equals(project) || dependency.dependsOn(project));
|
||||
}
|
||||
|
||||
public boolean skipTests() {
|
||||
return this.skipTests;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see java.lang.Comparable#compareTo(java.lang.Object)
|
||||
|
||||
@@ -20,6 +20,7 @@ import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.jgrapht.graph.DefaultDirectedGraph;
|
||||
import org.jgrapht.graph.DefaultEdge;
|
||||
@@ -45,10 +46,10 @@ public class Projects {
|
||||
MONGO_DB = new Project("DATAMONGO", "MongoDB", Arrays.asList(COMMONS),
|
||||
ArtifactCoordinates.NONE.artifacts("spring-data-mongodb-cross-store", "spring-data-mongodb-log4j"));
|
||||
NEO4J = new Project("DATAGRAPH", "Neo4j", Arrays.asList(COMMONS));
|
||||
SOLR = new Project("DATASOLR", "Solr", Arrays.asList(COMMONS));
|
||||
SOLR = new Project("DATASOLR", "Solr", Arrays.asList(COMMONS)).withFullName("Spring Data for Apache Solr");
|
||||
COUCHBASE = new Project("DATACOUCH", "Couchbase", Arrays.asList(COMMONS));
|
||||
CASSANDRA = new Project("DATACASS", "Cassandra", Arrays.asList(COMMONS),
|
||||
ArtifactCoordinates.NONE.artifacts("spring-cql"));
|
||||
ArtifactCoordinates.NONE.artifacts("spring-cql")).withFullName("Spring Data for Apache Cassandra");
|
||||
ELASTICSEARCH = new Project("DATAES", "Elasticsearch", Arrays.asList(COMMONS));
|
||||
KEY_VALUE = new Project("DATAKV", "KeyValue", Arrays.asList(COMMONS));
|
||||
REDIS = new Project("DATAREDIS", "Redis", Arrays.asList(COMMONS, KEY_VALUE));
|
||||
@@ -87,11 +88,16 @@ public class Projects {
|
||||
PROJECTS = Collections.unmodifiableList(intermediate);
|
||||
}
|
||||
|
||||
public static Project byName(String name) {
|
||||
public static Optional<Project> byName(String name) {
|
||||
|
||||
return PROJECTS.stream().//
|
||||
filter(project -> project.getName().equalsIgnoreCase(name) || project.getKey().toString().equals(name)).//
|
||||
findFirst()
|
||||
.orElseThrow(() -> new IllegalArgumentException(String.format("No project named %s available!", name)));
|
||||
findFirst();
|
||||
}
|
||||
|
||||
public static Project requiredByName(String name) {
|
||||
|
||||
return byName(name).//
|
||||
orElseThrow(() -> new IllegalArgumentException(String.format("No project named %s available!", name)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,6 +48,13 @@ public class ProjectUnitTests {
|
||||
*/
|
||||
@Test
|
||||
public void findsProjectByKey() {
|
||||
assertThat(Projects.byName("DATACMNS"), is(Projects.COMMONS));
|
||||
assertThat(Projects.requiredByName("DATACMNS"), is(Projects.COMMONS));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void returnsCustomFullNameIfSet() {
|
||||
|
||||
assertThat(Projects.BUILD.getFullName(), is("Spring Data Build"));
|
||||
assertThat(Projects.CASSANDRA.getFullName(), is("Spring Data for Apache Cassandra"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user