Skip to content

Commit

Permalink
#610: Adding the possibility to skip version resolution alogether if …
Browse files Browse the repository at this point in the history
…parentVersion is tru
  • Loading branch information
andrzejj0 committed Sep 14, 2022
1 parent 07f2ced commit 4de9c46
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 6 deletions.
2 changes: 2 additions & 0 deletions src/it/it-update-parent-005-issue-610/invoker.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:update-parent
invoker.mavenOpts = -DparentVersion=999 -DskipResolution=true
16 changes: 16 additions & 0 deletions src/it/it-update-parent-005-issue-610/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<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-parent4</artifactId>
<version>70</version>
</parent>

<groupId>localhsot</groupId>
<artifactId>issue-670</artifactId>
<version>0.31-SNAPSHOT</version>
<packaging>pom</packaging>

</project>
3 changes: 3 additions & 0 deletions src/it/it-update-parent-005-issue-610/verify.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pom = new File( basedir, "pom.xml" ).text

assert pom =~ /<version>999<\/version>/
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.apache.maven.plugins.annotations.Parameter;
import org.codehaus.mojo.versions.api.PomHelper;
import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader;
import org.codehaus.mojo.versions.utils.DependencyBuilder;

import static org.apache.maven.shared.utils.StringUtils.isBlank;

Expand Down Expand Up @@ -157,7 +158,7 @@ protected void update( ModifiedPomXMLEventReader pom )
private ArtifactVersion resolveTargetVersion( String initialVersion )
throws MojoExecutionException, ArtifactMetadataRetrievalException, InvalidVersionSpecificationException
{
Artifact artifact = getHelper().createDependencyArtifact( org.codehaus.mojo.versions.DependencyBuilder
Artifact artifact = getHelper().createDependencyArtifact( DependencyBuilder
.newBuilder()
.withGroupId( getProject().getParent().getGroupId() )
.withArtifactId( getProject().getParent().getArtifactId() )
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.codehaus.mojo.versions;
package org.codehaus.mojo.versions.utils;

import org.apache.maven.model.Dependency;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.apache.maven.repository.RepositorySystem;
import org.codehaus.mojo.versions.api.PomHelper;
import org.codehaus.mojo.versions.change.VersionChange;
import org.codehaus.mojo.versions.utils.DependencyBuilder;
import org.codehaus.mojo.versions.utils.TestChangeRecorder;
import org.hamcrest.core.Is;
import org.junit.Before;
Expand Down Expand Up @@ -213,9 +214,11 @@ public void testPoisonDependencyVersion()
throws MojoExecutionException, XMLStreamException, MojoFailureException, IllegalAccessException
{
mojo.getProject().getModel().setDependencies( Arrays.asList(
DependencyBuilder.dependencyWith( "default-group", "dependency-artifact", "1.1.1-SNAPSHOT",
DependencyBuilder.dependencyWith( "default-group", "dependency-artifact",
"1.1.1-SNAPSHOT",
"default", "pom", SCOPE_COMPILE ),
DependencyBuilder.dependencyWith( "default-group", "poison-artifact", "1.1.1.1-SNAPSHOT",
DependencyBuilder.dependencyWith( "default-group", "poison-artifact",
"1.1.1.1-SNAPSHOT",
"default", "pom", SCOPE_COMPILE )
) );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import java.util.Set;

import org.apache.maven.model.Dependency;
import org.codehaus.mojo.versions.DependencyBuilder;
import org.codehaus.mojo.versions.utils.DependencyBuilder;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.codehaus.mojo.versions.filtering;

import org.apache.maven.model.Dependency;
import org.codehaus.mojo.versions.DependencyBuilder;
import org.codehaus.mojo.versions.utils.DependencyBuilder;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
Expand Down

0 comments on commit 4de9c46

Please sign in to comment.