Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#291 display-dependency-updates: introduce switch processDependencyManagementTransitive #588

Merged
merged 3 commits into from
May 5, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
#291 add integration tests
  • Loading branch information
stefanseifert committed Apr 28, 2022
commit 00180c056b8eb35c1509b57bd58d60ba8b33cd67
25 changes: 25 additions & 0 deletions src/it-repo/dummy-api-impl-bom-pom-1.0.pom
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
invoker.goals=${project.groupId}:${project.artifactId}:${project.version}:display-dependency-updates
invoker.mavenOpts=-DprocessDependencyManagementTransitive=false
Original file line number Diff line number Diff line change
@@ -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>
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
invoker.goals=${project.groupId}:${project.artifactId}:${project.version}:display-dependency-updates
invoker.mavenOpts=-DprocessDependencyManagementTransitive=true
Original file line number Diff line number Diff line change
@@ -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>
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
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