More stuff.
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
io.workDir=~/temp/spring-data-shell
|
||||
|
||||
git.author=Oliver Gierke <ogierke@pivotal.io>
|
||||
git.username=olivergierke
|
||||
git.author=Oliver Gierke
|
||||
git.email=ogierke@pivotal.io
|
||||
7
pom.xml
7
pom.xml
@@ -72,6 +72,13 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jgit</groupId>
|
||||
<artifactId>org.eclipse.jgit</artifactId>
|
||||
<version>4.0.1.201506240215-r</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
@@ -79,6 +79,6 @@ public class AnnouncementOperations {
|
||||
public static void main(String[] args) {
|
||||
|
||||
AnnouncementOperations operations = new AnnouncementOperations();
|
||||
System.out.println(operations.getProjectBulletpoints(new TrainIteration(ReleaseTrains.CODD, Iteration.SR2)));
|
||||
System.out.println(operations.getProjectBulletpoints(new TrainIteration(ReleaseTrains.FOWLER, Iteration.SR1)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ public class StaticResources {
|
||||
}
|
||||
|
||||
public String getDocumentationUrl() {
|
||||
return baseUrl.concat("/reference/htmlsingle");
|
||||
return baseUrl.concat("/reference/html");
|
||||
}
|
||||
|
||||
public String getJavaDocUrl() {
|
||||
|
||||
@@ -31,7 +31,7 @@ import org.springframework.util.Assert;
|
||||
@EqualsAndHashCode
|
||||
class Branch {
|
||||
|
||||
private static final Branch MASTER = new Branch("master");
|
||||
public static final Branch MASTER = new Branch("master");
|
||||
|
||||
private final String name;
|
||||
|
||||
|
||||
@@ -22,11 +22,27 @@ import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
import org.eclipse.jgit.api.CheckoutCommand;
|
||||
import org.eclipse.jgit.api.CreateBranchCommand.SetupUpstreamMode;
|
||||
import org.eclipse.jgit.api.Git;
|
||||
import org.eclipse.jgit.api.ResetCommand.ResetType;
|
||||
import org.eclipse.jgit.lib.ObjectId;
|
||||
import org.eclipse.jgit.lib.Ref;
|
||||
import org.eclipse.jgit.lib.Repository;
|
||||
import org.eclipse.jgit.revwalk.RevCommit;
|
||||
import org.eclipse.jgit.revwalk.RevWalk;
|
||||
import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
|
||||
import org.eclipse.jgit.transport.CredentialsProvider;
|
||||
import org.eclipse.jgit.transport.RefSpec;
|
||||
import org.eclipse.jgit.transport.TagOpt;
|
||||
import org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.data.release.io.CommandResult;
|
||||
import org.springframework.data.release.io.OsCommandOperations;
|
||||
import org.springframework.data.release.io.Workspace;
|
||||
import org.springframework.data.release.jira.IssueTracker;
|
||||
import org.springframework.data.release.jira.Ticket;
|
||||
@@ -42,7 +58,6 @@ import org.springframework.data.release.utils.Logger;
|
||||
import org.springframework.plugin.core.PluginRegistry;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Component to execut Git related operations.
|
||||
@@ -54,12 +69,19 @@ import org.springframework.util.StringUtils;
|
||||
public class GitOperations {
|
||||
|
||||
private final GitServer server = new GitServer();
|
||||
private final OsCommandOperations os;
|
||||
private final Workspace workspace;
|
||||
private final Logger logger;
|
||||
private final PluginRegistry<IssueTracker, Project> issueTracker;
|
||||
private final Environment environment;
|
||||
|
||||
private CredentialsProvider credentials;
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
this.credentials = new UsernamePasswordCredentialsProvider(environment.getProperty("git.username"),
|
||||
environment.getProperty("git.password"));
|
||||
}
|
||||
|
||||
public GitProject getGitProject(Project project) {
|
||||
return new GitProject(project, server);
|
||||
}
|
||||
@@ -78,8 +100,15 @@ public class GitOperations {
|
||||
|
||||
Branch branch = Branch.from(module);
|
||||
|
||||
CommandUtils.getCommandResult(
|
||||
os.executeCommand(String.format("git reset --hard origin/%s", branch), module.getProject()));
|
||||
try (Git git = new Git(getRepository(module.getProject()))) {
|
||||
|
||||
logger.log(module, "git reset --hard origin/%s", branch);
|
||||
|
||||
git.reset().//
|
||||
setMode(ResetType.HARD).//
|
||||
setRef("origin/".concat(branch.toString())).//
|
||||
call();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,7 +135,11 @@ public class GitOperations {
|
||||
String.format("No tag found for version %s of project %s, aborting.", artifactVersion, project));
|
||||
}
|
||||
|
||||
CommandUtils.getCommandResult(os.executeCommand(String.format("git checkout %s", tag), project));
|
||||
try (Git git = new Git(getRepository(module.getProject()))) {
|
||||
|
||||
logger.log(module, "git checkout %s", tag);
|
||||
git.checkout().setStartPoint(tag.toString());
|
||||
}
|
||||
}
|
||||
|
||||
logger.log(iteration, "Successfully checked out projects.");
|
||||
@@ -118,10 +151,16 @@ public class GitOperations {
|
||||
|
||||
Branch branch = Branch.from(module);
|
||||
|
||||
CommandUtils.getCommandResult(update(module.getProject()));
|
||||
update(module.getProject());
|
||||
|
||||
String checkoutCommand = String.format("git checkout %s && git pull origin %s", branch, branch);
|
||||
CommandUtils.getCommandResult(os.executeCommand(checkoutCommand, module.getProject()));
|
||||
logger.log(module.getProject(), "git checkout %s && git pull origin %s", branch, branch);
|
||||
checkout(module.getProject(), branch);
|
||||
|
||||
try (Git git = new Git(getRepository(module.getProject()))) {
|
||||
git.pull().//
|
||||
setRebase(true).//
|
||||
call();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,7 +169,7 @@ public class GitOperations {
|
||||
List<Future<CommandResult>> executions = new ArrayList<>();
|
||||
|
||||
for (Module module : train) {
|
||||
executions.add(update(module.getProject()));
|
||||
update(module.getProject());
|
||||
}
|
||||
|
||||
for (Future<CommandResult> execution : executions) {
|
||||
@@ -143,54 +182,80 @@ public class GitOperations {
|
||||
for (ModuleIteration module : iteration) {
|
||||
|
||||
Branch branch = Branch.from(module);
|
||||
CommandUtils
|
||||
.getCommandResult(os.executeCommand(String.format("git push origin %s", branch), module.getProject()));
|
||||
|
||||
logger.log(module, "git push origin %s", branch);
|
||||
|
||||
try (Git git = new Git(getRepository(module.getProject()))) {
|
||||
|
||||
Ref ref = git.getRepository().getRef(branch.toString());
|
||||
|
||||
git.push().//
|
||||
setRemote("origin").//
|
||||
setRefSpecs(new RefSpec(ref.getName())).//
|
||||
setCredentialsProvider(credentials).//
|
||||
call();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void pushTags(Train train) throws Exception {
|
||||
|
||||
for (Module module : train) {
|
||||
CommandUtils.getCommandResult(os.executeCommand("git push --tags", module.getProject()));
|
||||
|
||||
logger.log(module.getProject(), "git push --tags");
|
||||
|
||||
try (Git git = new Git(getRepository(module.getProject()))) {
|
||||
|
||||
git.push().//
|
||||
setRemote("origin").//
|
||||
setPushTags().//
|
||||
setCredentialsProvider(this.credentials).//
|
||||
call();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Future<CommandResult> update(Project project) throws Exception {
|
||||
public void update(Project project) throws Exception {
|
||||
|
||||
GitProject gitProject = new GitProject(project, server);
|
||||
String repositoryName = gitProject.getRepositoryName();
|
||||
|
||||
if (workspace.hasProjectDirectory(project)) {
|
||||
Repository repository = getRepository(project);
|
||||
|
||||
logger.log(project, "Found existing repository %s. Obtaining latest changes…", repositoryName);
|
||||
try (Git git = new Git(repository)) {
|
||||
|
||||
return os.executeCommand("git checkout master && git reset --hard && git fetch --tags && git pull origin master",
|
||||
project);
|
||||
if (workspace.hasProjectDirectory(project)) {
|
||||
|
||||
} else {
|
||||
logger.log(project, "Found existing repository %s. Obtaining latest changes…", repositoryName);
|
||||
logger.log(project, "git checkout master && git reset --hard && git fetch --tags && git pull origin master");
|
||||
|
||||
logger.log(project, "No repository found! Cloning from %s…", gitProject.getProjectUri());
|
||||
checkout(project, Branch.MASTER);
|
||||
|
||||
File projectDirectory = workspace.getProjectDirectory(project);
|
||||
String command = String.format("git clone %s %s", gitProject.getProjectUri(), projectDirectory.getName());
|
||||
git.reset().setMode(ResetType.HARD).call();
|
||||
|
||||
return os.executeCommand(command);
|
||||
git.fetch().setTagOpt(TagOpt.FETCH_TAGS);
|
||||
|
||||
git.pull().call();
|
||||
|
||||
// return os.executeCommand("git checkout master && git reset --hard && git fetch --tags && git pull origin
|
||||
// master",
|
||||
// project);
|
||||
|
||||
} else {
|
||||
|
||||
logger.log(project, "No repository found! Cloning from %s…", gitProject.getProjectUri());
|
||||
clone(project);
|
||||
|
||||
// return os.executeCommand(command);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Tags getTags(Project project) throws Exception {
|
||||
|
||||
String result = os.executeForResult("git tag -l", project);
|
||||
List<Tag> tags = new ArrayList<>();
|
||||
|
||||
for (String line : result.split("\n")) {
|
||||
|
||||
if (!StringUtils.isEmpty(line)) {
|
||||
tags.add(new Tag(line));
|
||||
}
|
||||
try (Git git = new Git(getRepository(project))) {
|
||||
return new Tags(git.tagList().call().stream().map(ref -> new Tag(ref.getName())).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
return new Tags(tags);
|
||||
}
|
||||
|
||||
public void tagRelease(TrainIteration iteration) throws Exception {
|
||||
@@ -200,16 +265,25 @@ public class GitOperations {
|
||||
Branch branch = Branch.from(module);
|
||||
Project project = module.getProject();
|
||||
|
||||
String checkoutCommand = String.format("git checkout %s", branch);
|
||||
CommandUtils.getCommandResult(os.executeCommand(checkoutCommand, project));
|
||||
try (Git git = new Git(getRepository(module.getProject()))) {
|
||||
|
||||
String updateCommand = String.format("git pull origin %s", branch);
|
||||
CommandUtils.getCommandResult(os.executeCommand(updateCommand, project));
|
||||
logger.log(module, "git checkout %s", branch);
|
||||
checkout(project, branch);
|
||||
|
||||
String hash = getReleaseHash(module);
|
||||
Tag tag = getTags(project).createTag(module);
|
||||
String tagCommand = String.format("git tag %s %s", tag, hash);
|
||||
CommandUtils.getCommandResult(os.executeCommand(tagCommand, project));
|
||||
logger.log(module, "git pull origin %s", branch);
|
||||
git.pull().call();
|
||||
|
||||
ObjectId hash = getReleaseHash(module);
|
||||
Tag tag = getTags(project).createTag(module);
|
||||
|
||||
try (RevWalk walk = new RevWalk(git.getRepository())) {
|
||||
|
||||
RevCommit commit = walk.parseCommit(hash);
|
||||
|
||||
logger.log(module, "git tag %s %s", tag, hash.getName());
|
||||
git.tag().setName(tag.toString()).setObjectId(commit).call();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -228,15 +302,20 @@ public class GitOperations {
|
||||
Assert.hasText(summary, "Summary must not be null or empty!");
|
||||
|
||||
for (ModuleIteration module : iteration) {
|
||||
|
||||
if (summary.contains("%s")) {
|
||||
summary = String.format(summary, module.getVersionString());
|
||||
}
|
||||
|
||||
commit(module, summary, details);
|
||||
commit(module, expandSummary(summary, module, iteration), details);
|
||||
}
|
||||
}
|
||||
|
||||
private String expandSummary(String summary, ModuleIteration module, TrainIteration iteration) {
|
||||
|
||||
if (!summary.contains("%s")) {
|
||||
return summary;
|
||||
}
|
||||
|
||||
return String.format(summary,
|
||||
ArtifactVersion.from(module).toString().concat(String.format(" (%s)", iteration.toString())));
|
||||
}
|
||||
|
||||
/**
|
||||
* Commits the given files for the given {@link ModuleIteration} using the given summary and details for the commit
|
||||
* message. If no files are given, all pending changes are commited.
|
||||
@@ -258,36 +337,36 @@ public class GitOperations {
|
||||
|
||||
Commit commit = new Commit(ticket, summary, details);
|
||||
String author = environment.getProperty("git.author");
|
||||
String commitCommand = String.format("git commit -m \"%s\" --author \"%s\"", commit, author);
|
||||
String email = environment.getProperty("git.email");
|
||||
|
||||
if (files.length != 0) {
|
||||
logger.log(module, "git commit -m \"%s\" --author=\"%s <%s>\"", commit, author, email);
|
||||
|
||||
for (File file : files) {
|
||||
os.executeCommand(String.format("git add %s", file.getAbsolutePath()), project).get();
|
||||
}
|
||||
try (Git git = new Git(getRepository(module.getProject()))) {
|
||||
|
||||
CommandUtils.getCommandResult(os.executeCommand(commitCommand, project));
|
||||
} else {
|
||||
CommandUtils.getCommandResult(os.executeCommand(commitCommand.concat(" -a"), project));
|
||||
git.commit().//
|
||||
setMessage(commit.toString()).//
|
||||
setAuthor(author, email).//
|
||||
setAll(true).//
|
||||
call();
|
||||
}
|
||||
}
|
||||
|
||||
private String getReleaseHash(ModuleIteration module) throws Exception {
|
||||
private ObjectId getReleaseHash(ModuleIteration module) throws Exception {
|
||||
|
||||
Project project = module.getProject();
|
||||
|
||||
String result = os.executeForResult("git log --pretty=format:'%h %s'", project);
|
||||
Ticket releaseTicket = issueTracker.getPluginFor(project).getReleaseTicketFor(module);
|
||||
String trigger = String.format("%s - Release", releaseTicket.getId());
|
||||
|
||||
logger.log(project, "Looking up release commit (ticket id %s)", releaseTicket.getId());
|
||||
try (Git git = new Git(getRepository(module.getProject()))) {
|
||||
|
||||
for (String line : result.split("\n")) {
|
||||
for (RevCommit commit : git.log().setMaxCount(50).call()) {
|
||||
|
||||
int summaryStart = line.indexOf(" ");
|
||||
String summary = commit.getShortMessage();
|
||||
|
||||
if (line.substring(summaryStart + 1).startsWith(trigger)) {
|
||||
return line.substring(0, summaryStart);
|
||||
if (summary.startsWith(trigger)) {
|
||||
return commit.getId();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -314,4 +393,37 @@ public class GitOperations {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void checkout(Project project, Branch branch) throws Exception {
|
||||
|
||||
try (Git git = new Git(getRepository(project))) {
|
||||
|
||||
Ref ref = git.getRepository().getRef(branch.toString());
|
||||
CheckoutCommand checkout = git.checkout().setName(branch.toString());
|
||||
|
||||
if (ref == null) {
|
||||
|
||||
checkout.setCreateBranch(true).//
|
||||
setUpstreamMode(SetupUpstreamMode.TRACK).//
|
||||
setStartPoint("origin/".concat(branch.toString()));
|
||||
}
|
||||
|
||||
checkout.call();
|
||||
}
|
||||
}
|
||||
|
||||
private Repository getRepository(Project project) throws Exception {
|
||||
return FileRepositoryBuilder.create(workspace.getFile(".git", project));
|
||||
}
|
||||
|
||||
public void clone(Project project) throws Exception {
|
||||
|
||||
Git git = Git.cloneRepository().//
|
||||
setURI(getGitProject(project).getProjectUri()).//
|
||||
setDirectory(workspace.getProjectDirectory(project)).//
|
||||
call();
|
||||
|
||||
git.checkout().setName(Branch.MASTER.toString()).//
|
||||
call();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ package org.springframework.data.release.git;
|
||||
*/
|
||||
public class GitServer {
|
||||
|
||||
private static final String SERVER_URI = "https://www.github.com/spring-projects/";
|
||||
private static final String SERVER_URI = "https://github.com/spring-projects/";
|
||||
|
||||
public String getUri() {
|
||||
return SERVER_URI;
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package org.springframework.data.release.gradle;
|
||||
|
||||
import static org.springframework.data.release.model.Projects.*;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -36,12 +37,13 @@ import org.springframework.stereotype.Component;
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
@Component
|
||||
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||
@RequiredArgsConstructor(onConstructor = @__(@Autowired) )
|
||||
public class GradleOperations {
|
||||
|
||||
private static final String BUILD_GRADLE = "build.gradle";
|
||||
private static final String GRADLE_PROPERTIES = "gradle.properties";
|
||||
private static final String COMMONS_PROPERTY = "springDataCommonsVersion";
|
||||
private static final String BUILD_PROPERTY = "springDataBuildVersion";
|
||||
|
||||
private final Workspace workspace;
|
||||
private final Logger logger;
|
||||
@@ -57,6 +59,7 @@ public class GradleOperations {
|
||||
|
||||
final Repository repository = new Repository(iteration.getIteration());
|
||||
final ArtifactVersion commonsVersion = iteration.getModuleVersion(COMMONS);
|
||||
final ArtifactVersion buildVersion = iteration.getModuleVersion(BUILD);
|
||||
|
||||
for (ModuleIteration module : iteration.getModulesExcept(BUILD)) {
|
||||
|
||||
@@ -75,15 +78,25 @@ public class GradleOperations {
|
||||
@Override
|
||||
public String doWith(String line, long number) {
|
||||
|
||||
if (!line.contains(COMMONS_PROPERTY)) {
|
||||
return line;
|
||||
if (line.contains(COMMONS_PROPERTY)) {
|
||||
|
||||
ArtifactVersion version = phase.equals(Phase.PREPARE) ? commonsVersion
|
||||
: commonsVersion.getNextDevelopmentVersion();
|
||||
|
||||
logger.log(project, "Setting Spring Data Commons version in %s to %s.", GRADLE_PROPERTIES, version);
|
||||
return String.format("%s=%s", COMMONS_PROPERTY, version);
|
||||
}
|
||||
|
||||
ArtifactVersion version = phase.equals(Phase.PREPARE) ? commonsVersion : commonsVersion
|
||||
.getNextDevelopmentVersion();
|
||||
if (line.contains(BUILD_PROPERTY)) {
|
||||
|
||||
logger.log(project, "Setting Spring Data Commons version in %s to %s.", GRADLE_PROPERTIES, version);
|
||||
return String.format("%s=%s", COMMONS_PROPERTY, version);
|
||||
ArtifactVersion version = phase.equals(Phase.PREPARE) ? buildVersion
|
||||
: buildVersion.getNextDevelopmentVersion();
|
||||
|
||||
logger.log(project, "Setting Spring Data Build version in %s to %s.", GRADLE_PROPERTIES, version);
|
||||
return String.format("%s=%s", BUILD_PROPERTY, version);
|
||||
}
|
||||
|
||||
return line;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package org.springframework.data.release.io;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
@@ -24,8 +26,6 @@ import java.util.concurrent.Future;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import org.apache.commons.exec.CommandLine;
|
||||
import org.apache.commons.exec.DefaultExecuteResultHandler;
|
||||
import org.apache.commons.exec.DefaultExecutor;
|
||||
@@ -46,7 +46,7 @@ import org.springframework.stereotype.Component;
|
||||
* @since 1.2.0
|
||||
*/
|
||||
@Component
|
||||
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||
@RequiredArgsConstructor(onConstructor = @__(@Autowired) )
|
||||
class CommonsExecOsCommandOperations implements OsCommandOperations {
|
||||
|
||||
private static final Map<String, String> ENVIRONMENT = new HashMap<>();
|
||||
@@ -131,19 +131,19 @@ class CommonsExecOsCommandOperations implements OsCommandOperations {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
|
||||
return new AsyncResult<CommandResult>(new CommandResult(resultHandler.getExitValue(), writer.toString(),
|
||||
resultHandler.getException()));
|
||||
return new AsyncResult<CommandResult>(
|
||||
new CommandResult(resultHandler.getExitValue(), writer.toString(), resultHandler.getException()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds {@code JAVA_HOME} to the ENVIRONMENT variables lookuing up the path to a Java 7.
|
||||
* Adds {@code JAVA_HOME} to the ENVIRONMENT variables looking up the path to a Java 7.
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
@PostConstruct
|
||||
public void initialize() throws Exception {
|
||||
|
||||
String javaHome = executeCommand("/usr/libexec/java_home -F -v 1.7 -a x86_64 -d64").get().getOutput();
|
||||
String javaHome = executeCommand("/usr/libexec/java_home -F -v 1.8 -a x86_64 -d64").get().getOutput();
|
||||
|
||||
if (javaHome.endsWith("\n")) {
|
||||
javaHome = javaHome.substring(0, javaHome.length() - 1);
|
||||
|
||||
@@ -18,11 +18,11 @@ package org.springframework.data.release.maven;
|
||||
import static org.springframework.data.release.model.Phase.*;
|
||||
import static org.springframework.data.release.model.Projects.*;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.GenericTypeResolver;
|
||||
import org.springframework.data.release.io.CommandResult;
|
||||
@@ -32,7 +32,6 @@ import org.springframework.data.release.model.ArtifactVersion;
|
||||
import org.springframework.data.release.model.ModuleIteration;
|
||||
import org.springframework.data.release.model.Phase;
|
||||
import org.springframework.data.release.model.Project;
|
||||
import org.springframework.data.release.model.Projects;
|
||||
import org.springframework.data.release.model.Train;
|
||||
import org.springframework.data.release.model.TrainIteration;
|
||||
import org.springframework.data.release.utils.Logger;
|
||||
@@ -45,7 +44,7 @@ import org.xmlbeam.io.XBFileIO;
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
@Component
|
||||
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||
@RequiredArgsConstructor(onConstructor = @__(@Autowired) )
|
||||
public class MavenOperations {
|
||||
|
||||
private static final String COMMONS_VERSION_PROPERTY = "springdata.commons";
|
||||
@@ -84,8 +83,6 @@ public class MavenOperations {
|
||||
updateBomPom(iteration, phase);
|
||||
|
||||
final Repository repository = new Repository(iteration.getIteration());
|
||||
final ArtifactVersion commonsVersion = iteration.getModuleVersion(COMMONS);
|
||||
final ArtifactVersion nextCommonsVersion = commonsVersion.getNextDevelopmentVersion();
|
||||
final ArtifactVersion buildVersion = iteration.getModuleVersion(BUILD);
|
||||
final ArtifactVersion nextBuildVersion = buildVersion.getNextDevelopmentVersion();
|
||||
|
||||
@@ -113,12 +110,21 @@ public class MavenOperations {
|
||||
@Override
|
||||
public Pom doWith(Pom pom) {
|
||||
|
||||
if (project.dependsOn(Projects.COMMONS)) {
|
||||
for (Project dependency : project.getDependencies()) {
|
||||
|
||||
ArtifactVersion version = CLEANUP.equals(phase) ? nextCommonsVersion : commonsVersion;
|
||||
logger.log(project, "Updating Spring Data Commons version dependecy to %s (setting property %s).", version,
|
||||
COMMONS_VERSION_PROPERTY);
|
||||
pom.setProperty(COMMONS_VERSION_PROPERTY, version);
|
||||
String dependencyProperty = dependency.getDependencyProperty();
|
||||
|
||||
if (pom.getProperty(dependencyProperty) == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ArtifactVersion dependencyVersion = iteration.getModuleVersion(dependency);
|
||||
ArtifactVersion version = CLEANUP.equals(phase) ? dependencyVersion.getNextDevelopmentVersion()
|
||||
: dependencyVersion;
|
||||
|
||||
logger.log(project, "Updating %s dependency version property %s to %s.", dependency.getFullName(),
|
||||
dependencyProperty, version);
|
||||
pom.setProperty(dependencyProperty, version);
|
||||
}
|
||||
|
||||
ArtifactVersion version = CLEANUP.equals(phase) ? nextBuildVersion : buildVersion;
|
||||
@@ -201,7 +207,11 @@ public class MavenOperations {
|
||||
|
||||
logger.log(BUILD, "%s", module);
|
||||
|
||||
pom.setDependencyVersion(artifact.getArtifactId(), version);
|
||||
pom.setDependencyManagementVersion(artifact.getArtifactId(), version);
|
||||
|
||||
for (String additionalArtifact : module.getProject().getAdditionalArtifacts()) {
|
||||
pom.setDependencyManagementVersion(additionalArtifact, version);
|
||||
}
|
||||
}
|
||||
|
||||
return pom;
|
||||
|
||||
@@ -55,9 +55,12 @@ public interface Pom {
|
||||
* @param artifactId
|
||||
* @param version
|
||||
*/
|
||||
@XBWrite("/project/dependencies/dependency[artifactId=''{0}'']/version")
|
||||
@XBWrite("/project/dependencies/dependency[artifactId=\"{0}\"]/version")
|
||||
Pom setDependencyVersion(String artifactId, @XBValue ArtifactVersion version);
|
||||
|
||||
@XBWrite("/project/dependencyManagement/dependencies/dependency[artifactId=\"{0}\"]/version")
|
||||
Pom setDependencyManagementVersion(String artifactId, @XBValue ArtifactVersion version);
|
||||
|
||||
public interface Repository {
|
||||
|
||||
@XBRead("child::id")
|
||||
|
||||
@@ -22,7 +22,7 @@ import org.springframework.data.release.model.Iteration;
|
||||
*/
|
||||
public class Repository {
|
||||
|
||||
private static final String BASE = "http://repo.spring.io/libs-";
|
||||
private static final String BASE = "https://repo.spring.io/libs-";
|
||||
|
||||
private final String id;
|
||||
private final String url;
|
||||
|
||||
@@ -15,13 +15,12 @@
|
||||
*/
|
||||
package org.springframework.data.release.misc;
|
||||
|
||||
import java.io.File;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.release.git.GitOperations;
|
||||
import org.springframework.data.release.io.Workspace;
|
||||
@@ -42,7 +41,7 @@ import org.springframework.util.Assert;
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
@Component
|
||||
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||
@RequiredArgsConstructor(onConstructor = @__(@Autowired) )
|
||||
public class ReleaseOperations {
|
||||
|
||||
private static final Set<String> CHANGELOG_LOCATIONS;
|
||||
@@ -98,8 +97,7 @@ public class ReleaseOperations {
|
||||
|
||||
if (processed) {
|
||||
|
||||
File file = workspace.getFile(location, module.getProject());
|
||||
git.commit(module, "Updated changelog.", null, file);
|
||||
git.commit(module, "Updated changelog.", null);
|
||||
|
||||
logger.log(module.getProject(), "Updated changelog %s.", location);
|
||||
}
|
||||
|
||||
@@ -28,7 +28,9 @@ import org.springframework.util.Assert;
|
||||
@Value
|
||||
public class Iteration {
|
||||
|
||||
public static final Iteration SR4 = new Iteration("SR4", null);
|
||||
public static final Iteration SR6 = new Iteration("SR6", null);
|
||||
public static final Iteration SR5 = new Iteration("SR6", SR6);
|
||||
public static final Iteration SR4 = new Iteration("SR4", SR5);
|
||||
public static final Iteration SR3 = new Iteration("SR3", SR4);
|
||||
public static final Iteration SR2 = new Iteration("SR2", SR3);
|
||||
public static final Iteration SR1 = new Iteration("SR1", SR2);
|
||||
|
||||
@@ -15,13 +15,13 @@
|
||||
*/
|
||||
package org.springframework.data.release.model;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -33,19 +33,25 @@ public class Project {
|
||||
|
||||
private final @Getter ProjectKey key;
|
||||
private final @Getter String name;
|
||||
private final List<Project> dependencies;
|
||||
private final @Getter List<Project> dependencies;
|
||||
private final Tracker tracker;
|
||||
private final @Getter List<String> additionalArtifacts;
|
||||
|
||||
Project(String key, String name, Project... dependencies) {
|
||||
this(key, name, Tracker.JIRA, dependencies);
|
||||
Project(String key, String name, List<Project> dependencies) {
|
||||
this(key, name, Tracker.JIRA, dependencies, Collections.emptyList());
|
||||
}
|
||||
|
||||
Project(String key, String name, Tracker tracker, Project... dependencies) {
|
||||
Project(String key, String name, List<Project> dependencies, List<String> additionalArtifacts) {
|
||||
this(key, name, Tracker.JIRA, dependencies, additionalArtifacts);
|
||||
}
|
||||
|
||||
Project(String key, String name, Tracker tracker, List<Project> dependencies, List<String> additionalArtifacts) {
|
||||
|
||||
this.key = new ProjectKey(key);
|
||||
this.name = name;
|
||||
this.dependencies = Arrays.asList(dependencies);
|
||||
this.dependencies = dependencies;
|
||||
this.tracker = tracker;
|
||||
this.additionalArtifacts = additionalArtifacts;
|
||||
}
|
||||
|
||||
public boolean uses(Tracker tracker) {
|
||||
@@ -56,6 +62,10 @@ public class Project {
|
||||
return "Spring Data ".concat(name);
|
||||
}
|
||||
|
||||
public String getDependencyProperty() {
|
||||
return "springdata.".concat(name.toLowerCase());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the current project depends on the given one.
|
||||
*
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package org.springframework.data.release.model;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -29,19 +30,21 @@ public class Projects {
|
||||
|
||||
static {
|
||||
|
||||
BUILD = new Project("DATABUILD", "Build", Tracker.GITHUB);
|
||||
COMMONS = new Project("DATACMNS", "Commons", BUILD);
|
||||
JPA = new Project("DATAJPA", "JPA", COMMONS);
|
||||
MONGO_DB = new Project("DATAMONGO", "MongoDB", COMMONS);
|
||||
NEO4J = new Project("DATAGRAPH", "Neo4j", COMMONS);
|
||||
SOLR = new Project("DATASOLR", "Solr", COMMONS);
|
||||
COUCHBASE = new Project("DATACOUCH", "Couchbase", COMMONS);
|
||||
CASSANDRA = new Project("DATACASS", "Cassandra", COMMONS);
|
||||
ELASTICSEARCH = new Project("DATAES", "Elasticsearch", COMMONS);
|
||||
REDIS = new Project("DATAREDIS", "Redis");
|
||||
GEMFIRE = new Project("SGF", "Gemfire", COMMONS);
|
||||
BUILD = new Project("DATABUILD", "Build", Tracker.GITHUB, Collections.emptyList(), Collections.emptyList());
|
||||
COMMONS = new Project("DATACMNS", "Commons", Arrays.asList(BUILD));
|
||||
JPA = new Project("DATAJPA", "JPA", Arrays.asList(COMMONS));
|
||||
MONGO_DB = new Project("DATAMONGO", "MongoDB", Arrays.asList(COMMONS),
|
||||
Arrays.asList("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));
|
||||
COUCHBASE = new Project("DATACOUCH", "Couchbase", Arrays.asList(COMMONS));
|
||||
CASSANDRA = new Project("DATACASS", "Cassandra", Arrays.asList(COMMONS), Arrays.asList("spring-cql"));
|
||||
ELASTICSEARCH = new Project("DATAES", "Elasticsearch", Arrays.asList(COMMONS));
|
||||
REDIS = new Project("DATAREDIS", "Redis", Collections.emptyList());
|
||||
GEMFIRE = new Project("SGF", "Gemfire", Arrays.asList(COMMONS));
|
||||
|
||||
REST = new Project("DATAREST", "REST", COMMONS, JPA, MONGO_DB, NEO4J, GEMFIRE);
|
||||
REST = new Project("DATAREST", "REST", Arrays.asList(COMMONS, JPA, MONGO_DB, NEO4J, GEMFIRE, SOLR, CASSANDRA),
|
||||
Arrays.asList("spring-data-rest-core", "spring-data-rest-core"));
|
||||
|
||||
PROJECTS = Arrays.asList(BUILD, COMMONS, JPA, MONGO_DB, NEO4J, SOLR, COUCHBASE, CASSANDRA, ELASTICSEARCH, REDIS,
|
||||
GEMFIRE, REST);
|
||||
|
||||
@@ -34,7 +34,7 @@ public class ReleaseTrains {
|
||||
CODD = codd();
|
||||
DIJKSTRA = dijkstra();
|
||||
EVANS = DIJKSTRA.next("Evans", Transition.MINOR);
|
||||
FOWLER = EVANS.next("Fowler", Transition.MAJOR);
|
||||
FOWLER = EVANS.next("Fowler", Transition.MINOR);
|
||||
|
||||
// Trains
|
||||
|
||||
|
||||
@@ -17,16 +17,16 @@ package org.springframework.data.release.model;
|
||||
|
||||
import static org.springframework.data.release.model.Iteration.*;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import lombok.Value;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import lombok.Value;
|
||||
|
||||
import org.springframework.shell.support.util.OsUtils;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
@@ -163,7 +163,7 @@ public class Train implements Iterable<Module> {
|
||||
@ToString
|
||||
public static class Iterations implements Iterable<Iteration> {
|
||||
|
||||
public static Iterations DEFAULT = new Iterations(M1, RC1, GA, SR1, SR2, SR3, SR4);
|
||||
public static Iterations DEFAULT = new Iterations(M1, RC1, GA, SR1, SR2, SR3, SR4, SR5, SR6);
|
||||
|
||||
private final List<Iteration> iterations;
|
||||
|
||||
|
||||
@@ -15,10 +15,10 @@
|
||||
*/
|
||||
package org.springframework.data.release.model;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import lombok.Value;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
@@ -65,6 +65,6 @@ public class TrainIteration implements Iterable<ModuleIteration> {
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("%s - %s", train.getName(), iteration.getName());
|
||||
return String.format("%s %s", train.getName(), iteration.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,4 +44,10 @@ public class GitOperationsIntegrationTests extends AbstractIntegrationTests {
|
||||
Tags tags = gitOperations.getTags(COMMONS);
|
||||
System.out.println(StringUtils.collectionToDelimitedString(tags.asList(), "\n"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void foo() throws Exception {
|
||||
|
||||
gitOperations.update(ReleaseTrains.EVANS);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import static org.junit.Assert.*;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.release.AbstractIntegrationTests;
|
||||
import org.springframework.data.release.model.Projects;
|
||||
|
||||
/**
|
||||
* @author Oliver Gierke
|
||||
@@ -32,12 +33,21 @@ public class CommonsExecOsCommandOperationsIntegegrationTests extends AbstractIn
|
||||
@Test
|
||||
public void testname() throws Exception {
|
||||
|
||||
CommandResult result = operations
|
||||
.executeCommand("git clone --progress https://github.com/spring-projects/spring-data-build").get();
|
||||
// CommandResult result = operations
|
||||
// .executeCommand("export GIT_TRACE=1 && git clone https://github.com/spring-projects/spring-data-build").get();
|
||||
|
||||
// CommandResult result = operations.executeCommand("git pull", Projects.BUILD).get();
|
||||
|
||||
CommandResult result = operations.executeCommand("git remote -v", Projects.BUILD).get();
|
||||
// .get();
|
||||
|
||||
if (result.hasError()) {
|
||||
|
||||
System.out.println(result.getStatus());
|
||||
System.out.println(result.getOutput());
|
||||
System.out.println(result.getException().getMessage());
|
||||
|
||||
throw result.getException();
|
||||
} else {
|
||||
System.out.println(result.getOutput());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user