Skip to content

Commit

Permalink
Provide a "change recorder" for updates
Browse files Browse the repository at this point in the history
This provides a ChangeRecorder interface that logs changes to a
machine-readable XML file whenever a pom.xml file is updated.

Closes #416 #356
  • Loading branch information
io7m authored and slachiewicz committed Apr 23, 2022
1 parent bf4fb54 commit a6a2d75
Show file tree
Hide file tree
Showing 40 changed files with 978 additions and 80 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</parent>

<artifactId>versions-maven-plugin</artifactId>
<version>2.10.1-SNAPSHOT</version>
<version>2.11.0-SNAPSHOT</version>
<packaging>maven-plugin</packaging>

<name>Versions Maven Plugin</name>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
invoker.goals=-DchangeRecorderFormat=xml ${project.groupId}:${project.artifactId}:${project.version}:update-parent
40 changes: 40 additions & 0 deletions src/it/it-changerecord-update-parent-001/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<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-parent</artifactId>
<version>1.0</version>
</parent>

<groupId>localhost</groupId>
<artifactId>it-201</artifactId>
<version>1.0</version>
<packaging>pom</packaging>
<name>update-parent basic test</name>

<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>2.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.3</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.2</version>
</plugin>
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>2.0</version>
</plugin>
</plugins>
</pluginManagement>
</build>

</project>
22 changes: 22 additions & 0 deletions src/it/it-changerecord-update-parent-001/verify.bsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import java.io.*;
import java.util.regex.*;
import org.codehaus.plexus.util.FileUtils;

try
{
File file = new File( basedir, "target/versions-changes.xml" );
String buf = FileUtils.fileRead( file, "UTF-8" );

if ( buf.indexOf( "<update artifactId=\"dummy-parent\" groupId=\"localhost\" kind=\"updateParent\" newVersion=\"3.0\" oldVersion=\"1.0\"/>" ) < 0 )
{
System.err.println( "Version change recorded" );
return false;
}
}
catch( Throwable t )
{
t.printStackTrace();
return false;
}

return true;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
invoker.goals=-DchangeRecorderFormat=xml ${project.groupId}:${project.artifactId}:${project.version}:update-properties
59 changes: 59 additions & 0 deletions src/it/it-changerecord-update-properties-001/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<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>localhost</groupId>
<artifactId>it-001</artifactId>
<version>1.0</version>
<packaging>pom</packaging>
<name>update-properties with one property only</name>

<properties>
<api>1.0</api>
</properties>

<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>2.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.3</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.2</version>
</plugin>
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>2.0</version>
</plugin>
</plugins>
</pluginManagement>

<plugins>
<plugin>
<groupId>@project.groupId@</groupId>
<artifactId>@project.artifactId@</artifactId>
<version>@project.version@</version>
<configuration>
<properties>
<property>
<name>api</name>
<dependencies>
<dependency>
<groupId>localhost</groupId>
<artifactId>dummy-api</artifactId>
</dependency>
</dependencies>
</property>
</properties>
</configuration>
</plugin>
</plugins>
</build>

</project>
21 changes: 21 additions & 0 deletions src/it/it-changerecord-update-properties-001/verify.bsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import java.io.*;
import org.codehaus.plexus.util.FileUtils;

try
{
File file = new File( basedir, "target/versions-changes.xml" );
String buf = FileUtils.fileRead( file, "UTF-8" );

if ( buf.indexOf( "<update artifactId=\"dummy-api\" groupId=\"localhost\" kind=\"updateProperty\" newVersion=\"3.0\" oldVersion=\"1.0\"/>" ) < 0 )
{
System.err.println( "Version change recorded" );
return false;
}
}
catch( Throwable t )
{
t.printStackTrace();
return false;
}

return true;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
invoker.goals=-DchangeRecorderFormat=xml ${project.groupId}:${project.artifactId}:${project.version}:use-latest-releases
21 changes: 21 additions & 0 deletions src/it/it-changerecord-use-latest-releases-001/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<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>localhost</groupId>
<artifactId>it-use-latest-releases-001</artifactId>
<version>1.0</version>
<packaging>pom</packaging>
<name>Update a dependency to the latest release version</name>

<dependencies>

<dependency>
<groupId>localhost</groupId>
<artifactId>dummy-api</artifactId>
<version>1.1.1-2</version>
</dependency>

</dependencies>

</project>
21 changes: 21 additions & 0 deletions src/it/it-changerecord-use-latest-releases-001/verify.bsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import java.io.*;
import org.codehaus.plexus.util.FileUtils;

try
{
File file = new File( basedir, "target/versions-changes.xml" );
String buf = FileUtils.fileRead( file, "UTF-8" );

if ( buf.indexOf( "<update artifactId=\"dummy-api\" groupId=\"localhost\" kind=\"useLatestReleases\" newVersion=\"3.0\" oldVersion=\"1.1.1-2\"/>" ) < 0 )
{
System.err.println( "Version change recorded" );
return false;
}
}
catch( Throwable t )
{
t.printStackTrace();
return false;
}

return true;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
invoker.goals=-DchangeRecorderFormat=xml ${project.groupId}:${project.artifactId}:${project.version}:use-latest-snapshots -DallowMinorUpdates=true
21 changes: 21 additions & 0 deletions src/it/it-changerecord-use-latest-snapshots-001/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<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>localhost</groupId>
<artifactId>it-use-latest-snapshots-001</artifactId>
<version>1.0</version>
<packaging>pom</packaging>
<name>Update a release dependency to the latest snapshot version</name>

<dependencies>

<dependency>
<groupId>localhost</groupId>
<artifactId>dummy-api</artifactId>
<version>1.0</version>
</dependency>

</dependencies>

</project>
21 changes: 21 additions & 0 deletions src/it/it-changerecord-use-latest-snapshots-001/verify.bsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import java.io.*;
import org.codehaus.plexus.util.FileUtils;

try
{
File file = new File( basedir, "target/versions-changes.xml" );
String buf = FileUtils.fileRead( file, "UTF-8" );

if ( buf.indexOf( "<update artifactId=\"dummy-api\" groupId=\"localhost\" kind=\"useLatestSnapshots\" newVersion=\"1.9.1-SNAPSHOT\" oldVersion=\"1.0\"/>" ) < 0 )
{
System.err.println( "Version change recorded" );
return false;
}
}
catch( Throwable t )
{
t.printStackTrace();
return false;
}

return true;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
invoker.goals=-DchangeRecorderFormat=xml ${project.groupId}:${project.artifactId}:${project.version}:use-latest-versions
21 changes: 21 additions & 0 deletions src/it/it-changerecord-use-latest-versions-001/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<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>localhost</groupId>
<artifactId>it-use-latest-versions-001</artifactId>
<version>1.0</version>
<packaging>pom</packaging>
<name>Update a dependency to the next release version</name>

<dependencies>

<dependency>
<groupId>localhost</groupId>
<artifactId>dummy-api</artifactId>
<version>1.1.1-2</version>
</dependency>

</dependencies>

</project>
21 changes: 21 additions & 0 deletions src/it/it-changerecord-use-latest-versions-001/verify.bsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import java.io.*;
import org.codehaus.plexus.util.FileUtils;

try
{
File file = new File( basedir, "target/versions-changes.xml" );
String buf = FileUtils.fileRead( file, "UTF-8" );

if ( buf.indexOf( "<update artifactId=\"dummy-api\" groupId=\"localhost\" kind=\"useLatestVersions\" newVersion=\"3.0\" oldVersion=\"1.1.1-2\"/>" ) < 0 )
{
System.err.println( "Version change recorded" );
return false;
}
}
catch( Throwable t )
{
t.printStackTrace();
return false;
}

return true;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
invoker.goals=-DchangeRecorderFormat=xml ${project.groupId}:${project.artifactId}:${project.version}:use-next-versions
21 changes: 21 additions & 0 deletions src/it/it-changerecord-use-next-versions-001/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<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>localhost</groupId>
<artifactId>it-use-next-versions-001</artifactId>
<version>1.0</version>
<packaging>pom</packaging>
<name>Update a dependency to the next versions</name>

<dependencies>

<dependency>
<groupId>localhost</groupId>
<artifactId>dummy-api</artifactId>
<version>1.1.1-2</version>
</dependency>

</dependencies>

</project>
21 changes: 21 additions & 0 deletions src/it/it-changerecord-use-next-versions-001/verify.bsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import java.io.*;
import org.codehaus.plexus.util.FileUtils;

try
{
File file = new File( basedir, "target/versions-changes.xml" );
String buf = FileUtils.fileRead( file, "UTF-8" );

if ( buf.indexOf( "<update artifactId=\"dummy-api\" groupId=\"localhost\" kind=\"useNextVersions\" newVersion=\"1.1.2\" oldVersion=\"1.1.1-2\"/>" ) < 0 )
{
System.err.println( "Version change recorded" );
return false;
}
}
catch( Throwable t )
{
t.printStackTrace();
return false;
}

return true;
Loading

0 comments on commit a6a2d75

Please sign in to comment.