Skip to content

Commit

Permalink
Ignoring dependency with no version in useReleases
Browse files Browse the repository at this point in the history
Closes #584 #584
  • Loading branch information
c3p0-maif authored and slachiewicz committed Apr 23, 2022
1 parent a57fabf commit bf4fb54
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/it/it-use-releases-issue-583/invoker.properties
@@ -0,0 +1 @@
invoker.goals=${project.groupId}:${project.artifactId}:${project.version}:use-releases -DallowRangeMatching=true -DfailIfNotReplaced=true
21 changes: 21 additions & 0 deletions src/it/it-use-releases-issue-583/pom.xml
@@ -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-releases-issue-583</artifactId>
<version>1.0</version>
<packaging>pom</packaging>
<name>Skip a dependency without version</name>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>localhost</groupId>
<artifactId>dummy-api</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
</dependencyManagement>

</project>
23 changes: 23 additions & 0 deletions src/it/it-use-releases-issue-583/verify.bsh
@@ -0,0 +1,23 @@
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 = Pattern.compile( "\\QIgnoring dependency with no version: localhost:dummy-api:jar\\E" );
Matcher m = p.matcher( buf.toString() );
if ( !m.find() )
{
System.out.println( "cannot find skipping of dummy-api dependency" );
return false;
}
}
catch( Throwable t )
{
t.printStackTrace();
return false;
}

return true;
Expand Up @@ -188,10 +188,11 @@ public boolean isExcludeReactor()
* @return true if the version starts with '${'
* @since 2.8
*/
protected boolean isHandledByProperty(Dependency dependency) {
String version = dependency.getVersion();
return version.startsWith("${");
}
protected boolean isHandledByProperty( Dependency dependency )
{
String version = dependency.getVersion();
return version != null && version.startsWith( "${" );
}

/**
* Try to find the dependency artifact that matches the given dependency.
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/org/codehaus/mojo/versions/UseReleasesMojo.java
Expand Up @@ -209,6 +209,11 @@ private void useReleases( ModifiedPomXMLEventReader pom, Collection<Dependency>
}

String version = dep.getVersion();
if ( version == null )
{
getLog().info( "Ignoring dependency with no version: " + toString( dep ) );
continue;
}
Matcher versionMatcher = matchSnapshotRegex.matcher( version );
if ( versionMatcher.matches() )
{
Expand Down

0 comments on commit bf4fb54

Please sign in to comment.