-
Notifications
You must be signed in to change notification settings - Fork 69
Add the tag name separator option (between ArtifactId and Version) #92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -46,7 +46,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { | |
| .credentialsProvider(getCredentialsProvider(log)) | ||
| .buildFromCurrentDir(); | ||
| ResolverWrapper resolverWrapper = new ResolverWrapper(factory, artifactResolver, remoteRepositories, localRepository); | ||
| Reactor reactor = Reactor.fromProjects(log, repo, project, projects, buildNumber, modulesToForceRelease, noChangesAction, resolverWrapper, versionNamer); | ||
| Reactor reactor = Reactor.fromProjects(log, repo, project, projects, buildNumber, modulesToForceRelease, noChangesAction, resolverWrapper, versionNamer, tagNameSeparator); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not ideal to make an excessively long list of parameters even longer. I have an upcoming PR that fixes this and I would appreciated if you could hold back this PR until then.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Of course, first come first served ! As soon as your PR is approved and merged, il will rebase and adapt mine. |
||
| if (reactor == null) { | ||
| return; | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| package e2e; | ||
|
|
||
| import org.apache.maven.shared.invoker.MavenInvocationException; | ||
| import org.eclipse.jgit.api.Git; | ||
| import org.eclipse.jgit.lib.ObjectId; | ||
| import org.junit.BeforeClass; | ||
| import org.junit.Test; | ||
| import scaffolding.MvnRunner; | ||
| import scaffolding.TestProject; | ||
|
|
||
| import java.io.IOException; | ||
| import java.util.List; | ||
|
|
||
| import static org.hamcrest.CoreMatchers.allOf; | ||
| import static org.hamcrest.CoreMatchers.containsString; | ||
| import static org.hamcrest.MatcherAssert.assertThat; | ||
| import static org.hamcrest.core.IsEqual.equalTo; | ||
| import static scaffolding.ExactCountMatcher.oneOf; | ||
| import static scaffolding.ExactCountMatcher.twoOf; | ||
| import static scaffolding.GitMatchers.hasCleanWorkingDirectory; | ||
| import static scaffolding.GitMatchers.hasTag; | ||
| import static scaffolding.MvnRunner.assertArtifactInLocalRepo; | ||
|
|
||
| public class InheritedVersionsWithTagNameSeparatorTest { | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test should be more focused on the actual change. So delete the copied tests around inheritance and rollbacks etc and just test that the tag separator logic is working. Include tests for invalid separators (i.e. things that are not allowed in git tags). |
||
|
|
||
| public static final String[] ARTIFACT_IDS = new String[]{"inherited-versions-from-parent", "core-utils", "console-app"}; | ||
| final String buildNumber = String.valueOf(System.currentTimeMillis()); | ||
| final String expected = "1.0." + buildNumber; | ||
| final TestProject testProject = TestProject.inheritedVersionsFromParentWithTagNameSeparator(); | ||
|
|
||
| @BeforeClass | ||
| public static void installPluginToLocalRepo() throws MavenInvocationException { | ||
| MvnRunner.installReleasePluginToLocalRepo(); | ||
| } | ||
|
|
||
| @Test | ||
| public void buildsAndInstallsAndTagsAllModules() throws Exception { | ||
| buildsEachProjectOnceAndOnlyOnce(testProject.mvnRelease(buildNumber)); | ||
| installsAllModulesIntoTheRepoWithTheBuildNumber(); | ||
| theLocalAndRemoteGitReposAreTaggedWithTheModuleNameAndVersion(); | ||
| } | ||
|
|
||
| private void buildsEachProjectOnceAndOnlyOnce(List<String> commandOutput) throws Exception { | ||
| assertThat( | ||
| commandOutput, | ||
| allOf( | ||
| oneOf(containsString("Going to release inherited-versions-from-parent " + expected)), | ||
| twoOf(containsString("Building inherited-versions-from-parent")), // once for initial build; once for release build | ||
| oneOf(containsString("Building core-utils")), | ||
| oneOf(containsString("Building console-app")), | ||
| oneOf(containsString("The Calculator Test has run")) | ||
| ) | ||
| ); | ||
| } | ||
|
|
||
| private void installsAllModulesIntoTheRepoWithTheBuildNumber() throws Exception { | ||
| assertArtifactInLocalRepo("com.github.danielflower.mavenplugins.testprojects.versioninheritor", "inherited-versions-from-parent", expected); | ||
| assertArtifactInLocalRepo("com.github.danielflower.mavenplugins.testprojects.versioninheritor", "core-utils", expected); | ||
| assertArtifactInLocalRepo("com.github.danielflower.mavenplugins.testprojects.versioninheritor", "console-app", expected); | ||
| } | ||
|
|
||
| private void theLocalAndRemoteGitReposAreTaggedWithTheModuleNameAndVersion() throws IOException, InterruptedException { | ||
| for (String artifactId : ARTIFACT_IDS) { | ||
| String expectedTag = artifactId + "/" + expected; | ||
| assertThat(testProject.local, hasTag(expectedTag)); | ||
| assertThat(testProject.origin, hasTag(expectedTag)); | ||
| } | ||
| } | ||
|
|
||
| @Test | ||
| public void thePomChangesAreRevertedAfterTheRelease() throws IOException, InterruptedException { | ||
| ObjectId originHeadAtStart = head(testProject.origin); | ||
| ObjectId localHeadAtStart = head(testProject.local); | ||
| assertThat(originHeadAtStart, equalTo(localHeadAtStart)); | ||
| testProject.mvnRelease(buildNumber); | ||
| assertThat(head(testProject.origin), equalTo(originHeadAtStart)); | ||
| assertThat(head(testProject.local), equalTo(localHeadAtStart)); | ||
| assertThat(testProject.local, hasCleanWorkingDirectory()); | ||
| } | ||
|
|
||
| // @Test | ||
| // public void whenOneModuleDependsOnAnotherThenWhenReleasingThisDependencyHasTheRelaseVersion() { | ||
| // // TODO: implement this | ||
| // } | ||
|
|
||
| private ObjectId head(Git git) throws IOException { | ||
| return git.getRepository().getRefDatabase().findRef("HEAD").getObjectId(); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| target | ||
| .idea/ | ||
| *.iml | ||
| .classpath | ||
| .settings | ||
| .project |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <project xmlns="http://maven.apache.org/POM/4.0.0" | ||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
| <parent> | ||
| <artifactId>inherited-versions-from-parent</artifactId> | ||
| <groupId>com.github.danielflower.mavenplugins.testprojects.versioninheritor</groupId> | ||
| <version>1.0-SNAPSHOT</version> | ||
| </parent> | ||
| <modelVersion>4.0.0</modelVersion> | ||
|
|
||
| <artifactId>console-app</artifactId> | ||
|
|
||
| <dependencies> | ||
| <dependency> | ||
| <groupId>com.github.danielflower.mavenplugins.testprojects.versioninheritor</groupId> | ||
| <artifactId>core-utils</artifactId> | ||
| <version>1.0-SNAPSHOT</version> | ||
| </dependency> | ||
| </dependencies> | ||
|
|
||
| </project> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| package com.github.danielflower.mavenplugins.testprojects.versioninheritor; | ||
|
|
||
| public class App { | ||
| public static void main(String[] args) { | ||
| Calculator calculator = new Calculator(); | ||
| System.out.println("1 + 2 = " + calculator.add(1, 2)); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <project xmlns="http://maven.apache.org/POM/4.0.0" | ||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
| <parent> | ||
| <artifactId>inherited-versions-from-parent</artifactId> | ||
| <groupId>com.github.danielflower.mavenplugins.testprojects.versioninheritor</groupId> | ||
| <version>1.0-SNAPSHOT</version> | ||
| </parent> | ||
| <modelVersion>4.0.0</modelVersion> | ||
|
|
||
| <artifactId>core-utils</artifactId> | ||
|
|
||
| <dependencies> | ||
| <dependency> | ||
| <groupId>junit</groupId> | ||
| <artifactId>junit</artifactId> | ||
| <version>4.11</version> | ||
| <scope>test</scope> | ||
| </dependency> | ||
| </dependencies> | ||
|
|
||
| </project> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| package com.github.danielflower.mavenplugins.testprojects.versioninheritor; | ||
|
|
||
| public class Calculator { | ||
|
|
||
| public int add(int a, int b) { | ||
| return a + b; | ||
| } | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| package com.github.danielflower.mavenplugins.testprojects.versioninheritor; | ||
|
|
||
|
|
||
| import org.junit.Assert; | ||
| import org.junit.Test; | ||
|
|
||
| public class CalculatorTest { | ||
|
|
||
| @Test | ||
| public void testAdd() throws Exception { | ||
| Assert.assertEquals(3, new Calculator().add(1, 2)); | ||
| System.out.println("The Calculator Test has run"); // used in a test to assert this has run | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <project xmlns="http://maven.apache.org/POM/4.0.0" | ||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
|
|
||
| <modelVersion>4.0.0</modelVersion> | ||
|
|
||
| <groupId>com.github.danielflower.mavenplugins.testprojects.versioninheritor</groupId> | ||
| <artifactId>inherited-versions-from-parent</artifactId> | ||
| <version>1.0-SNAPSHOT</version> | ||
| <modules> | ||
| <module>core-utils</module> | ||
| <module>console-app</module> | ||
| </modules> | ||
| <packaging>pom</packaging> | ||
|
|
||
| <properties> | ||
| <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
| </properties> | ||
|
|
||
| <build> | ||
| <plugins> | ||
| <plugin> | ||
| <groupId>com.github.danielflower.mavenplugins</groupId> | ||
| <artifactId>multi-module-maven-release-plugin</artifactId> | ||
| <version>${current.plugin.version}</version> | ||
| <configuration> | ||
| <releaseGoals> | ||
| <releaseGoal>install</releaseGoal> | ||
| </releaseGoals> | ||
| <tagNameSeparator>/</tagNameSeparator> | ||
| </configuration> | ||
| </plugin> | ||
| </plugins> | ||
| </build> | ||
| </project> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this documentation needs more detail about what this is for and what tags look like, which is
{artifactid}-{version}(doesn't actually have groupid). Maybe this should actually be a string like{artifactid}-{version}and the code just does a string replace on {artifactid} and {version}. There could be {groupid} too.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok I will try to do that. That's what i will implement :
if my custom tag name parameter contains at least substrings "{artifactId}" and "{version}" (minimum required to guarantee uniqueness of a git tag) then do a
else log a warn and use default value
{artifactid}-{version}There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh wait, would that complicate the tag lookups in the part of the code that guesses the next build number? (It's been a while since I worked on this so can't really remember)