Skip to content

Commit

Permalink
#291 add integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanseifert committed Apr 28, 2022
1 parent 36c3232 commit 00180c0
Show file tree
Hide file tree
Showing 9 changed files with 273 additions and 13 deletions.
25 changes: 25 additions & 0 deletions src/it-repo/dummy-api-impl-bom-pom-1.0.pom
@@ -0,0 +1,25 @@
<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>dummy-api-impl-bom-pom</artifactId>
<version>1.0</version>
<packaging>pom</packaging>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>localhost</groupId>
<artifactId>dummy-api</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>localhost</groupId>
<artifactId>dummy-impl</artifactId>
<version>1.2</version>
</dependency>
</dependencies>
</dependencyManagement>

</project>
25 changes: 25 additions & 0 deletions src/it-repo/dummy-api-impl-bom-pom-2.0.pom
@@ -0,0 +1,25 @@
<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>dummy-api-impl-bom-pom</artifactId>
<version>2.0</version>
<packaging>pom</packaging>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>localhost</groupId>
<artifactId>dummy-api</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>localhost</groupId>
<artifactId>dummy-impl</artifactId>
<version>2.1</version>
</dependency>
</dependencies>
</dependencyManagement>

</project>
@@ -0,0 +1,2 @@
invoker.goals=${project.groupId}:${project.artifactId}:${project.version}:display-dependency-updates
invoker.mavenOpts=-DprocessDependencyManagementTransitive=false
@@ -0,0 +1,58 @@
<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-display-dependency-updates-001</artifactId>
<version>1.0</version>
<packaging>pom</packaging>
<name>display-dependency-updates</name>
<url>http://localhost/</url>
<dependencies>
<dependency>
<groupId>localhost</groupId>
<artifactId>dummy-api</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>localhost</groupId>
<artifactId>dummy-api-impl-bom-pom</artifactId>
<version>1.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>localhost</groupId>
<artifactId>dummy-maven-plugin</artifactId>
<version>1.0</version>
</plugin>
<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>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>2.1</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
@@ -0,0 +1,45 @@
import java.io.*;
import org.codehaus.plexus.util.FileUtils;
import java.util.regex.*;

try
{
File file = new File( basedir, "build.log" );
String buf = FileUtils.fileRead( file );

Pattern p;
Matcher m;

p = Pattern.compile( "\\Qlocalhost:dummy-api\\E\\s*\\.*\\s*1\\.1\\s+->\\s+3\\.0" );
m = p.matcher( buf.toString() );
if ( !m.find() )
{
System.out.println( "Did not suggest updating dummy-api to version 3.0" );
return false;
}
System.out.println( m.group( 0 ) );

p = Pattern.compile( "\\Qlocalhost:dummy-impl\\E\\s*\\.*\\s*1\\.2\\s+->\\s+2\\.2" );
m = p.matcher( buf.toString() );
if ( m.find() )
{
System.out.println( "Did suggest updating dummy-impl to version 2.2" );
return false;
}

p = Pattern.compile( "\\Qlocalhost:dummy-api-impl-bom-pom\\E\\s*\\.*\\s*1\\.0\\s+->\\s+2\\.0" );
m = p.matcher( buf.toString() );
if ( !m.find() )
{
System.out.println( "Did not suggest updating dummy-api-impl-bom-pom to version 2.0" );
return false;
}
System.out.println( m.group( 0 ) );
}
catch( Throwable t )
{
t.printStackTrace();
return false;
}

return true;
@@ -0,0 +1,2 @@
invoker.goals=${project.groupId}:${project.artifactId}:${project.version}:display-dependency-updates
invoker.mavenOpts=-DprocessDependencyManagementTransitive=true
@@ -0,0 +1,58 @@
<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-display-dependency-updates-001</artifactId>
<version>1.0</version>
<packaging>pom</packaging>
<name>display-dependency-updates</name>
<url>http://localhost/</url>
<dependencies>
<dependency>
<groupId>localhost</groupId>
<artifactId>dummy-api</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>localhost</groupId>
<artifactId>dummy-api-impl-bom-pom</artifactId>
<version>1.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>localhost</groupId>
<artifactId>dummy-maven-plugin</artifactId>
<version>1.0</version>
</plugin>
<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>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>2.1</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
@@ -0,0 +1,45 @@
import java.io.*;
import org.codehaus.plexus.util.FileUtils;
import java.util.regex.*;

try
{
File file = new File( basedir, "build.log" );
String buf = FileUtils.fileRead( file );

Pattern p;
Matcher m;

p = Pattern.compile( "\\Qlocalhost:dummy-api\\E\\s*\\.*\\s*1\\.1\\s+->\\s+3\\.0" );
m = p.matcher( buf.toString() );
if ( !m.find() )
{
System.out.println( "Did not suggest updating dummy-api to version 3.0" );
return false;
}
System.out.println( m.group( 0 ) );

p = Pattern.compile( "\\Qlocalhost:dummy-impl\\E\\s*\\.*\\s*1\\.2\\s+->\\s+2\\.2" );
m = p.matcher( buf.toString() );
if ( !m.find() )
{
System.out.println( "Did not suggest updating dummy-impl to version 2.2" );
return false;
}
System.out.println( m.group( 0 ) );

p = Pattern.compile( "\\Qlocalhost:dummy-api-impl-bom-pom\\E\\s*\\.*\\s*1\\.0\\s+->\\s+2\\.0" );
m = p.matcher( buf.toString() );
if ( m.find() )
{
System.out.println( "Did suggest updating dummy-api-impl-bom-pom to version 2.0" );
return false;
}
}
catch( Throwable t )
{
t.printStackTrace();
return false;
}

return true;
Expand Up @@ -78,6 +78,19 @@ public class DisplayDependencyUpdatesMojo
@Parameter( property = "processDependencyManagement", defaultValue = "true" )
private boolean processDependencyManagement;

/**
* Whether to process the depdendencyManagement part transitive or not.
* In case of <code>&lt;type&gt;pom&lt;/type&gt;</code>and
* <code>&lt;scope&gt;import&lt;/scope&gt;</code> this means
* by default to report also the imported dependencies.
* If processTransitive is set to <code>false</code> the report will only show
* updates of the imported pom it self.
*
* @since 2.5 Note: Currently in experimental state.
*/
@Parameter( property = "processDependencyManagementTransitive", defaultValue = "true" )
private boolean processDependencyManagementTransitive;

/**
* Whether to process the dependencies section of the project.
*
Expand Down Expand Up @@ -151,19 +164,6 @@ public class DisplayDependencyUpdatesMojo
@Parameter( property = "verbose", defaultValue = "false" )
private boolean verbose;

/**
* Whether to process the depdendencyManagement part transitive or not.
* In case of <code>&lt;type&gt;pom&lt;/type&gt;</code>and
* <code>&lt;scope&gt;import&lt;/scope&gt;</code> this means
* by default to report also the imported dependencies.
* If processTransitive is set to <code>false</code> the report will only show
* updates of the imported pom it self.
*
* @since 2.5 Note: Currently in experimental state.
*/
@Parameter( property = "processDependencyManagementTransitive", defaultValue = "true" )
private boolean processDependencyManagementTransitive;

// --------------------- GETTER / SETTER METHODS ---------------------

private static Set<Dependency> extractPluginDependenciesFromPluginsInPluginManagement( Build build )
Expand Down

0 comments on commit 00180c0

Please sign in to comment.