Skip to content

Commit

Permalink
Resolves #289: Handle processParent in mojos which support it.
Browse files Browse the repository at this point in the history
Also:
- added failIfNotReplaced to ForceReleasesMojo as a first steps towards converging with UseReleasesMojo
- enhanced documentation on UseReleasesMojo#allowRangeMatching
- streamlined UseReleasesMojo in order to converge it with ForceReleasesMojo and then fold further with other similar mojos
- added unit tests and integration tests
- some refactoring
  • Loading branch information
andrzejj0 authored and slawekjaranowski committed Nov 17, 2022
1 parent c50851f commit 2c78f43
Show file tree
Hide file tree
Showing 41 changed files with 716 additions and 770 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ target
.project
*.iml
.idea
.checkstyle
/.factorypath
Original file line number Diff line number Diff line change
Expand Up @@ -253,4 +253,5 @@ public String toString()
return "ArtifactVersions" + "{artifact=" + artifact + ", versions=" + versions + ", versionComparator="
+ versionComparator + '}';
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ public ArtifactVersionsCache( BiFunction<AbstractVersionDetails, Optional<Segmen
* If the information is already present in cache, the cached version is returned. Otherwise,
* the {@code artifactVersions} object is queried and the response is cached.
*
* @param <V> concrete implementation of {@linkplain AbstractVersionDetails}
* @param <R> return type of the cached function
* @param artifactVersions {@linkplain ArtifactVersions} object referring to the given dependency
* @param updateScope update scope
* @return last retrieved update information
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -492,4 +492,5 @@ public int getSegmentCount( ArtifactVersion v )
return result;
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
*/

import java.io.OutputStream;
import java.util.Objects;

/**
* A recorder that ignores updates.
Expand All @@ -29,35 +28,20 @@
public class ChangeRecorderNull implements ChangeRecorder
{
/**
* Create a new change recorder that serializes to XML.
*
* @return A new change recorder
* Creates a new instance
*/

public static ChangeRecorder create()
{
return new ChangeRecorderNull();
}

private ChangeRecorderNull()
public ChangeRecorderNull()
{

}

@Override
public final void recordUpdate( final String kind, final String groupId, final String artifactId,
final String oldVersion, final String newVersion )
{
Objects.requireNonNull( kind, "kind" );
Objects.requireNonNull( groupId, "groupId" );
Objects.requireNonNull( artifactId, "artifactId" );
Objects.requireNonNull( oldVersion, "oldVersion" );
Objects.requireNonNull( newVersion, "newVersion" );
}

@Override
public final void serialize( final OutputStream outputStream )
{

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,34 +53,24 @@ public class ChangeRecorderXML implements ChangeRecorder
private final Element root;

/**
* Create a new change recorder that serializes to XML.
*
* @return A new change recorder
* Creates a new instance
*/

public static ChangeRecorder create()
public ChangeRecorderXML()
{
try
{
final DocumentBuilderFactory documentBuilders = DocumentBuilderFactory.newInstance();
final DocumentBuilder documentBuilder = documentBuilders.newDocumentBuilder();
final Document document = documentBuilder.newDocument();
final Element root = document.createElementNS( CHANGES_NAMESPACE, "updates" );
document = documentBuilder.newDocument();
root = document.createElementNS( CHANGES_NAMESPACE, "updates" );
document.appendChild( root );
return new ChangeRecorderXML( document, root );
}
catch ( final ParserConfigurationException | DOMException e )
{
throw new IllegalStateException( e );
}
}

private ChangeRecorderXML( final Document document, final Element root )
{
this.document = Objects.requireNonNull( document, "document" );
this.root = Objects.requireNonNull( root, "root" );
}

@Override
public final void recordUpdate( final String kind, final String groupId, final String artifactId,
final String oldVersion, final String newVersion )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ public static DependencyBuilder newBuilder()

/**
* Convenience builder method
* @param groupId groupId of the dependency
* @param artifactId artifactId of the dependency
* @param version version of the dependency
* @return new instance of {@linkplain Dependency}
*/
public static Dependency dependencyWith( String groupId, String artifactId, String version )
Expand All @@ -157,6 +160,12 @@ public static Dependency dependencyWith( String groupId, String artifactId, Stri

/**
* Convenience builder method
* @param groupId groupId of the dependency
* @param artifactId artifactId of the dependency
* @param version version of the dependency
* @param type type of the dependency
* @param classifier classifier of the dependency
* @param scope scope of the dependency
* @return new instance of {@linkplain Dependency}
*/
public static Dependency dependencyWith( String groupId, String artifactId, String version, String type,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public void testChanges() throws Exception

copyResource( "expectedFile.xml", file0 );

final ChangeRecorder recorder = ChangeRecorderXML.create();
final ChangeRecorder recorder = new ChangeRecorderXML();
recorder.recordUpdate( "exampleKind", "org.codehaus", "example0", "0.0.1", "0.0.2" );
recorder.recordUpdate( "exampleKind", "org.codehaus", "example1", "1.0.0", "2.0.0" );

Expand Down
15 changes: 15 additions & 0 deletions versions-maven-plugin/src/it-repo/dummy-with-parent.pom
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<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>

<parent>
<groupId>localhost</groupId>
<artifactId>dummy-parent2</artifactId>
<version>2.0</version>
</parent>

<artifactId>dummy-with-parent</artifactId>
<version>1.0</version>
<packaging>pom</packaging>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:compare-dependencies
invoker.mavenOpts = -DremotePom=localhost:dummy-with-parent:1.0 -DreportMode=false -DprocessParent=true
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<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>

<parent>
<groupId>localhost</groupId>
<artifactId>dummy-parent2</artifactId>
<version>1.0</version>
</parent>

<artifactId>dummy-with-parent</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def project = new XmlSlurper().parse( new File( basedir, 'pom.xml' ) )
assert project.parent.version == '2.0'
33 changes: 0 additions & 33 deletions versions-maven-plugin/src/it/it-use-latest-versions-009/verify.bsh

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def project = new XmlSlurper().parse( new File( basedir, 'pom.xml' ) )
assert project.parent.version == '3.0'
62 changes: 0 additions & 62 deletions versions-maven-plugin/src/it/it-use-latest-versions-010/verify.bsh

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def project = new XmlSlurper().parse( new File( basedir, 'pom.xml' ) )
assert project.parent.version == '3.0'
33 changes: 0 additions & 33 deletions versions-maven-plugin/src/it/it-use-latest-versions-011/verify.bsh

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def project = new XmlSlurper().parse( new File( basedir, 'pom.xml' ) )
assert project.parent.version == '1.0.0'
Loading

0 comments on commit 2c78f43

Please sign in to comment.