Skip to content

Commit

Permalink
[MINSTALL-160] Generated POM is not installed if original POM exists (#…
Browse files Browse the repository at this point in the history
…36)

When using generatePom=true with install-file Mojo, it will despite
this copy existing POM if it is found embedded in JAR (and if it
was built with Maven, it will find it).

The generatePom should reuse POM values embedded from JAR
but should generate (and install) new "empty POM" instead.
  • Loading branch information
cstamas authored Jul 19, 2022
1 parent 0008052 commit 23ab053
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
3 changes: 2 additions & 1 deletion src/it/MINSTALL-52/verify.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ assert new File( basedir, "../../local-repo/org/apache/maven/plugins/install/its

File buildLog = new File( basedir, 'build.log' )
assert buildLog.exists()
assert buildLog.text.contains( "[DEBUG] Using META-INF/maven/org.apache.maven.plugins.install.its/minstall52/pom.xml as pomFile" )
assert buildLog.text.contains( "[DEBUG] Loading META-INF/maven/org.apache.maven.plugins.install.its/minstall52/pom.xml" )
assert buildLog.text.contains( "[DEBUG] Using JAR embedded POM as pomFile" )
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,11 @@ public void execute()
else
{
temporaryPom = readingPomFromJarFile();
pomFile = temporaryPom;
if ( !Boolean.TRUE.equals( generatePom ) )
{
pomFile = temporaryPom;
getLog().debug( "Using JAR embedded POM as pomFile" );
}
}

if ( groupId == null || artifactId == null || version == null || packaging == null )
Expand Down Expand Up @@ -322,7 +326,7 @@ private File readingPomFromJarFile()

if ( pomEntry.matcher( entry.getName() ).matches() )
{
getLog().debug( "Using " + entry.getName() + " as pomFile" );
getLog().debug( "Loading " + entry.getName() );

InputStream pomInputStream = null;
OutputStream pomOutputStream = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,6 @@ public void testBasicInstallFile()
assignValuesForParameter( mojo );

mojo.execute();

File pomFile = (File) getVariableValueFromObject( mojo, "pomFile" );
org.codehaus.plexus.util.FileUtils.forceDelete( pomFile );

File installedArtifact = new File( getBasedir(), LOCAL_REPO + groupId + "/" + artifactId + "/" + version + "/" +
artifactId + "-" + version + "." + packaging );
Expand Down Expand Up @@ -122,9 +119,6 @@ public void testInstallFileWithClassifier()

mojo.execute();

File pomFile = (File) getVariableValueFromObject( mojo, "pomFile" );
org.codehaus.plexus.util.FileUtils.forceDelete( pomFile );

File installedArtifact = new File( getBasedir(), LOCAL_REPO + groupId + "/" + artifactId + "/" + version + "/" +
artifactId + "-" + version + "-" + classifier + "." + packaging );

Expand Down

0 comments on commit 23ab053

Please sign in to comment.