-
Notifications
You must be signed in to change notification settings - Fork 267
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#265: Processing all child modules instead of relying on default mave…
…n processing
- Loading branch information
1 parent
37e8947
commit e7aa406
Showing
13 changed files
with
359 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<project> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>localhost</groupId> | ||
<artifactId>dummy-artifact</artifactId> | ||
<version>OLD</version> | ||
<packaging>pom</packaging> | ||
|
||
<modules> | ||
<module>../module-a</module> | ||
</modules> | ||
|
||
<profiles> | ||
<profile> | ||
<id>module-b</id> | ||
|
||
<modules> | ||
<module>../module-b</module> | ||
</modules> | ||
</profile> | ||
</profiles> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
invoker.goals.1 = ${project.groupId}:${project.artifactId}:${project.version}:set -f aggregate/pom.xml | ||
invoker.mavenOpts.1 = -DnewVersion=1.2.3 -DprocessAllModules | ||
|
||
invoker.goals.2 = ${project.groupId}:${project.artifactId}:${project.version}:revert -f aggregate/pom.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<project> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>localhost</groupId> | ||
<artifactId>dummy-artifact-a</artifactId> | ||
<version>1.0.0</version> | ||
<packaging>pom</packaging> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>localhost</groupId> | ||
<artifactId>dummy-artifact</artifactId> | ||
<version>OLD</version> | ||
</dependency> | ||
</dependencies> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<project> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>localhost</groupId> | ||
<artifactId>dummy-artifact-b</artifactId> | ||
<version>1.0.0</version> | ||
<packaging>pom</packaging> | ||
|
||
<dependencyManagement> | ||
<dependencies> | ||
<dependency> | ||
<groupId>localhost</groupId> | ||
<artifactId>dummy-artifact</artifactId> | ||
<version>OLD</version> | ||
</dependency> | ||
</dependencies> | ||
</dependencyManagement> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
assert new File( basedir, "aggregate/pom.xml" ).text =~ /OLD/ | ||
assert !new File( basedir, "aggregate/pom.xml.versionsBackup" ).exists() | ||
|
||
assert new File( basedir, "module-a/pom.xml" ).text =~ /OLD/ | ||
assert !new File( basedir, "module-a/pom.xml.versionsBackup" ).exists() | ||
|
||
assert new File( basedir, "module-b/pom.xml" ).text =~ /OLD/ | ||
assert !new File( basedir, "module-b/pom.xml.versionsBackup" ).exists() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
src/test/java/org/codehaus/mojo/versions/RevertMojoTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
package org.codehaus.mojo.versions; | ||
|
||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import java.io.File; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.util.Arrays; | ||
import java.util.Objects; | ||
|
||
import org.apache.maven.plugin.testing.AbstractMojoTestCase; | ||
import org.apache.maven.plugin.testing.MojoRule; | ||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.Rule; | ||
|
||
import static java.lang.String.join; | ||
import static org.apache.commons.io.FileUtils.copyDirectory; | ||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.Matchers.containsString; | ||
import static org.hamcrest.core.Is.is; | ||
|
||
/** | ||
* Unit tests for {@link RevertMojo} | ||
* | ||
* @author Andrzej Jarmoniuk | ||
*/ | ||
public class RevertMojoTest extends AbstractMojoTestCase | ||
{ | ||
@Rule | ||
public MojoRule mojoRule = new MojoRule( this ); | ||
private Path pomDir; | ||
|
||
@Before | ||
public void setUp() throws Exception | ||
{ | ||
super.setUp(); | ||
pomDir = Files.createTempDirectory( "revert-" ); | ||
} | ||
|
||
@After | ||
public void tearDown() throws Exception | ||
{ | ||
try | ||
{ | ||
if ( pomDir != null && pomDir.toFile().exists() ) | ||
{ | ||
Arrays.stream( Objects.requireNonNull( pomDir.toFile().listFiles() ) ).forEach( File::delete ); | ||
pomDir.toFile().delete(); | ||
} | ||
} | ||
finally | ||
{ | ||
super.tearDown(); | ||
} | ||
} | ||
|
||
public void testRevert() throws Exception | ||
{ | ||
copyDirectory( new File( getBasedir(), | ||
"target/test-classes/org/codehaus/mojo/revert/issue-265" ), pomDir.toFile() ); | ||
RevertMojo myMojo = (RevertMojo) mojoRule.lookupConfiguredMojo( | ||
new File( pomDir.toString(), "aggregate" ), "revert" ); | ||
myMojo.execute(); | ||
|
||
assertThat( join( "\n", Files.readAllLines( pomDir.resolve( "aggregate/pom.xml" ) ) ), | ||
containsString( "OLD" ) ); | ||
assertThat( Files.exists( pomDir.resolve( "aggregate/pom.xml.versionsBackup" ) ), is( false ) ); | ||
assertThat( join( "\n", Files.readAllLines( pomDir.resolve( "module-a/pom.xml" ) ) ), | ||
containsString( "OLD" ) ); | ||
assertThat( Files.exists( pomDir.resolve( "module-a/pom.xml.versionsBackup" ) ), is( false ) ); | ||
assertThat( join( "\n", Files.readAllLines( pomDir.resolve( "module-b/pom.xml" ) ) ), | ||
containsString( "OLD" ) ); | ||
assertThat( Files.exists( pomDir.resolve( "module-b/pom.xml.versionsBackup" ) ), is( false ) ); | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
src/test/resources/org/codehaus/mojo/revert/issue-265/aggregate/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<!-- | ||
~ Licensed to the Apache Software Foundation (ASF) under one | ||
~ or more contributor license agreements. See the NOTICE file | ||
~ distributed with this work for additional information | ||
~ regarding copyright ownership. The ASF licenses this file | ||
~ to you under the Apache License, Version 2.0 (the | ||
~ "License"); you may not use this file except in compliance | ||
~ with the License. You may obtain a copy of the License at | ||
~ | ||
~ http://www.apache.org/licenses/LICENSE-2.0 | ||
~ | ||
~ Unless required by applicable law or agreed to in writing, | ||
~ software distributed under the License is distributed on an | ||
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
~ KIND, either express or implied. See the License for the | ||
~ specific language governing permissions and limitations | ||
~ under the License. | ||
--> | ||
|
||
<project> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>localhost</groupId> | ||
<artifactId>dummy-artifact</artifactId> | ||
<version>NEW</version> | ||
<packaging>pom</packaging> | ||
|
||
<modules> | ||
<module>../module-a</module> | ||
</modules> | ||
|
||
<profiles> | ||
<profile> | ||
<id>module-b</id> | ||
|
||
<modules> | ||
<module>../module-b</module> | ||
</modules> | ||
</profile> | ||
</profiles> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.codehaus.mojo</groupId> | ||
<artifactId>versions-maven-plugin</artifactId> | ||
<goals> | ||
<goal>revert</goal> | ||
</goals> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
21 changes: 21 additions & 0 deletions
21
src/test/resources/org/codehaus/mojo/revert/issue-265/aggregate/pom.xml.versionsBackup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<project> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>localhost</groupId> | ||
<artifactId>dummy-artifact</artifactId> | ||
<version>OLD</version> | ||
<packaging>pom</packaging> | ||
|
||
<modules> | ||
<module>../module-a</module> | ||
</modules> | ||
|
||
<profiles> | ||
<profile> | ||
<id>module-b</id> | ||
|
||
<modules> | ||
<module>../module-b</module> | ||
</modules> | ||
</profile> | ||
</profiles> | ||
</project> |
15 changes: 15 additions & 0 deletions
15
src/test/resources/org/codehaus/mojo/revert/issue-265/module-a/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<project> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>localhost</groupId> | ||
<artifactId>dummy-artifact-a</artifactId> | ||
<version>1.0.0</version> | ||
<packaging>pom</packaging> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>localhost</groupId> | ||
<artifactId>dummy-artifact</artifactId> | ||
<version>NEW</version> | ||
</dependency> | ||
</dependencies> | ||
</project> |
15 changes: 15 additions & 0 deletions
15
src/test/resources/org/codehaus/mojo/revert/issue-265/module-a/pom.xml.versionsBackup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<project> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>localhost</groupId> | ||
<artifactId>dummy-artifact-a</artifactId> | ||
<version>1.0.0</version> | ||
<packaging>pom</packaging> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>localhost</groupId> | ||
<artifactId>dummy-artifact</artifactId> | ||
<version>OLD</version> | ||
</dependency> | ||
</dependencies> | ||
</project> |
Oops, something went wrong.