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

Fixing #604: npe in DependencyVersionChanger if artifact version is null #655

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/it/it-set-024-versionless-dependency/child/pom.xml
@@ -0,0 +1,13 @@
<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>test-artifact</artifactId>
<version>1.0</version>
</parent>

<artifactId>child</artifactId>

</project>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing new line 😄

@@ -0,0 +1 @@
invoker.goals=${project.groupId}:${project.artifactId}:${project.version}:set -DprocessDependencies=true, -DartifactId=child -DoldVersion=1.0 -DnewVersion=2.0
22 changes: 22 additions & 0 deletions src/it/it-set-024-versionless-dependency/pom.xml
@@ -0,0 +1,22 @@
<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>test-artifact</artifactId>
<version>1.0</version>
<packaging>pom</packaging>

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

<modules>
<module>child</module>
</modules>
</project>
11 changes: 6 additions & 5 deletions src/main/java/org/codehaus/mojo/versions/SetMojo.java
Expand Up @@ -354,15 +354,16 @@ public void execute() throws MojoExecutionException, MojoFailureException
final String mGroupId = PomHelper.getGroupId( m );
final String mArtifactId = PomHelper.getArtifactId( m );
final String mVersion = PomHelper.getVersion( m );
if ( ( ( groupIdRegex.matcher( mGroupId ).matches() && artifactIdRegex.matcher( mArtifactId )
.matches() ) //
|| ( processAllModules ) ) //
&& oldVersionIdRegex.matcher( mVersion ).matches() && !newVersion.equals( mVersion ) )
if ( ( processAllModules
|| groupIdRegex.matcher( mGroupId ).matches()
&& artifactIdRegex.matcher( mArtifactId ).matches() )
&& oldVersionIdRegex.matcher( mVersion ).matches()
&& !newVersion.equals( mVersion ) )
{
found = true;
// if the change is not one we have swept up already
applyChange( project, reactor, files, mGroupId, m.getArtifactId(),
StringUtils.isBlank( oldVersion ) || "*".equals( oldVersion ) ? "" : m.getVersion() );
StringUtils.isBlank( oldVersion ) || "*".equals( oldVersion ) ? "" : mVersion );
}
}
if ( !found && RegexUtils.getWildcardScore( groupId ) == 0 && RegexUtils.getWildcardScore( artifactId ) == 0
Expand Down