Skip to content

Commit

Permalink
Fixed mojohaus#237
Browse files Browse the repository at this point in the history
Adding parent processing to UseLatestVersion/UseLatestSnapshot/UseLatestRelease

Change-Id: Iee03438288d7345569dc6aed27c628fef12caa7d
  • Loading branch information
Julian Di Leonardo committed Jan 3, 2018
1 parent 7bce2bf commit 4e87d5d
Show file tree
Hide file tree
Showing 21 changed files with 610 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/it/it-use-latest-releases-006/invoker.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
invoker.goals=${project.groupId}:${project.artifactId}:${project.version}:use-latest-releases
39 changes: 39 additions & 0 deletions src/it/it-use-latest-releases-006/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<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-use-latest-releases-006</artifactId>
<version>1.0</version>
<packaging>pom</packaging>
<name>Update a parent dependency</name>

<dependencies>

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

</dependencies>

<build>
<plugins>
<plugin>
<groupId>@project.groupId@</groupId>
<artifactId>@project.artifactId@</artifactId>
<version>@project.version@</version>
<configuration>
<processParent>true</processParent>
</configuration>
</plugin>
</plugins>
</build>

</project>
33 changes: 33 additions & 0 deletions src/it/it-use-latest-releases-006/verify.bsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import java.io.*;
import java.util.regex.*;

try
{
File file = new File( basedir, "pom.xml" );

BufferedReader in = new BufferedReader( new InputStreamReader( new FileInputStream( file ), "UTF-8" ) );
StringBuilder buf = new StringBuilder();
String line = in.readLine();
while ( line != null )
{
buf.append( line );
buf.append( " " );
line = in.readLine();
}

Pattern p = Pattern.compile( "\\Q<parent>\\E.*\\Q<version>\\E\\s*3\\.0\\s*\\Q</version>\\E.*\\Q</parent>\\E" );
Matcher m = p.matcher( buf.toString() );
if ( !m.find() )
{
System.out.println( "Did not update parent to version 3.0" );
return false;
}
System.out.println( m.group( 0 ) );
}
catch( Throwable t )
{
t.printStackTrace();
return false;
}

return true;
1 change: 1 addition & 0 deletions src/it/it-use-latest-releases-007/invoker.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
invoker.goals=${project.groupId}:${project.artifactId}:${project.version}:use-latest-releases
46 changes: 46 additions & 0 deletions src/it/it-use-latest-releases-007/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<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-use-latest-release-007</artifactId>
<version>1.0</version>
<packaging>pom</packaging>
<name>Update matching parent and dependency declaration</name>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>localhost</groupId>
<artifactId>dummy-impl</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>localhost</groupId>
<artifactId>dummy-parent</artifactId>
<version>1.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<build>
<plugins>
<plugin>
<groupId>@project.groupId@</groupId>
<artifactId>@project.artifactId@</artifactId>
<version>@project.version@</version>
<configuration>
<processParent>true</processParent>
</configuration>
</plugin>
</plugins>
</build>

</project>
62 changes: 62 additions & 0 deletions src/it/it-use-latest-releases-007/verify.bsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import java.io.*;
import java.util.regex.*;

try
{
File file = new File( basedir, "pom.xml" );

BufferedReader in = new BufferedReader( new InputStreamReader( new FileInputStream( file ), "UTF-8" ) );
StringBuilder buf = new StringBuilder();
String line = in.readLine();
while ( line != null )
{
buf.append( line );
buf.append( " " );
line = in.readLine();
}

Pattern p = Pattern.compile( "\\Q<parent>\\E.*\\Q<version>\\E\\s*3\\.0\\s*\\Q</version>\\E.*\\Q</parent>\\E" );
Matcher m = p.matcher( buf.toString() );
if ( !m.find() )
{
System.out.println( "Did not update parent to version 3.0" );
return false;
}
System.out.println( m.group( 0 ) );
}
catch( Throwable t )
{
t.printStackTrace();
return false;
}

try
{
File file = new File( basedir, "pom.xml" );

BufferedReader in = new BufferedReader( new InputStreamReader( new FileInputStream( file ), "UTF-8" ) );
StringBuilder buf = new StringBuilder();
String line = in.readLine();
while ( line != null )
{
buf.append( line );
buf.append( " " );
line = in.readLine();
}

Pattern p = Pattern.compile( "\\Q<version>\\E\\s*3\\.0\\s*\\Q</version>\\E.*\\Q<type>pom</type>\\E" );
Matcher m = p.matcher( buf.toString() );
if ( !m.find() )
{
System.out.println( "Did not update to version 3.0" );
return false;
}
System.out.println( m.group( 0 ) );
}
catch( Throwable t )
{
t.printStackTrace();
return false;
}

return true;
1 change: 1 addition & 0 deletions src/it/it-use-latest-snapshots-003/invoker.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
invoker.goals=${project.groupId}:${project.artifactId}:${project.version}:use-latest-snapshots
41 changes: 41 additions & 0 deletions src/it/it-use-latest-snapshots-003/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<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>

<groupId>localhost</groupId>
<artifactId>it-use-latest-snapshots-003</artifactId>
<version>1.0</version>
<packaging>pom</packaging>
<name>Update a parent dependency</name>

<dependencies>

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

</dependencies>

<build>
<plugins>
<plugin>
<groupId>@project.groupId@</groupId>
<artifactId>@project.artifactId@</artifactId>
<version>@project.version@</version>
<configuration>
<processParent>true</processParent>
<allowMajorUpdates>true</allowMajorUpdates>
<allowMinorUpdates>true</allowMinorUpdates>
</configuration>
</plugin>
</plugins>
</build>

</project>
33 changes: 33 additions & 0 deletions src/it/it-use-latest-snapshots-003/verify.bsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import java.io.*;
import java.util.regex.*;

try
{
File file = new File( basedir, "pom.xml" );

BufferedReader in = new BufferedReader( new InputStreamReader( new FileInputStream( file ), "UTF-8" ) );
StringBuilder buf = new StringBuilder();
String line = in.readLine();
while ( line != null )
{
buf.append( line );
buf.append( " " );
line = in.readLine();
}

Pattern p = Pattern.compile( "\\Q<parent>\\E.*\\Q<version>\\E\\s*3\\.0-SNAPSHOT\\s*\\Q</version>\\E.*\\Q</parent>\\E" );
Matcher m = p.matcher( buf.toString() );
if ( !m.find() )
{
System.out.println( "Did not update parent to version 3.0-SNAPSHOT" );
return false;
}
System.out.println( m.group( 0 ) );
}
catch( Throwable t )
{
t.printStackTrace();
return false;
}

return true;
1 change: 1 addition & 0 deletions src/it/it-use-latest-snapshots-004/invoker.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
invoker.goals=${project.groupId}:${project.artifactId}:${project.version}:use-latest-snapshots
48 changes: 48 additions & 0 deletions src/it/it-use-latest-snapshots-004/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<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>

<groupId>localhost</groupId>
<artifactId>it-use-latest-snapshots-004</artifactId>
<version>1.0</version>
<packaging>pom</packaging>
<name>Update matching parent and dependency declaration</name>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>localhost</groupId>
<artifactId>dummy-impl</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>localhost</groupId>
<artifactId>dummy-parent2</artifactId>
<version>1.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<build>
<plugins>
<plugin>
<groupId>@project.groupId@</groupId>
<artifactId>@project.artifactId@</artifactId>
<version>@project.version@</version>
<configuration>
<processParent>true</processParent>
<allowMajorUpdates>true</allowMajorUpdates>
<allowMinorUpdates>true</allowMinorUpdates>
</configuration>
</plugin>
</plugins>
</build>

</project>
62 changes: 62 additions & 0 deletions src/it/it-use-latest-snapshots-004/verify.bsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import java.io.*;
import java.util.regex.*;

try
{
File file = new File( basedir, "pom.xml" );

BufferedReader in = new BufferedReader( new InputStreamReader( new FileInputStream( file ), "UTF-8" ) );
StringBuilder buf = new StringBuilder();
String line = in.readLine();
while ( line != null )
{
buf.append( line );
buf.append( " " );
line = in.readLine();
}

Pattern p = Pattern.compile( "\\Q<parent>\\E.*\\Q<version>\\E\\s*3\\.0-SNAPSHOT\\s*\\Q</version>\\E.*\\Q</parent>\\E" );
Matcher m = p.matcher( buf.toString() );
if ( !m.find() )
{
System.out.println( "Did not update parent to version 3.0" );
return false;
}
System.out.println( m.group( 0 ) );
}
catch( Throwable t )
{
t.printStackTrace();
return false;
}

try
{
File file = new File( basedir, "pom.xml" );

BufferedReader in = new BufferedReader( new InputStreamReader( new FileInputStream( file ), "UTF-8" ) );
StringBuilder buf = new StringBuilder();
String line = in.readLine();
while ( line != null )
{
buf.append( line );
buf.append( " " );
line = in.readLine();
}

Pattern p = Pattern.compile( "\\Q<version>\\E\\s*3\\.0-SNAPSHOT\\s*\\Q</version>\\E.*\\Q<type>pom</type>\\E" );
Matcher m = p.matcher( buf.toString() );
if ( !m.find() )
{
System.out.println( "Did not update to version 3.0" );
return false;
}
System.out.println( m.group( 0 ) );
}
catch( Throwable t )
{
t.printStackTrace();
return false;
}

return true;
1 change: 1 addition & 0 deletions src/it/it-use-latest-versions-009/invoker.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
invoker.goals=${project.groupId}:${project.artifactId}:${project.version}:use-latest-versions
Loading

0 comments on commit 4e87d5d

Please sign in to comment.