Skip to content

Commit 23ab053

Browse files
authored
[MINSTALL-160] Generated POM is not installed if original POM exists (#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.
1 parent 0008052 commit 23ab053

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

src/it/MINSTALL-52/verify.groovy

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,5 @@ assert new File( basedir, "../../local-repo/org/apache/maven/plugins/install/its
2222

2323
File buildLog = new File( basedir, 'build.log' )
2424
assert buildLog.exists()
25-
assert buildLog.text.contains( "[DEBUG] Using META-INF/maven/org.apache.maven.plugins.install.its/minstall52/pom.xml as pomFile" )
25+
assert buildLog.text.contains( "[DEBUG] Loading META-INF/maven/org.apache.maven.plugins.install.its/minstall52/pom.xml" )
26+
assert buildLog.text.contains( "[DEBUG] Using JAR embedded POM as pomFile" )

src/main/java/org/apache/maven/plugins/install/InstallFileMojo.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,11 @@ public void execute()
206206
else
207207
{
208208
temporaryPom = readingPomFromJarFile();
209-
pomFile = temporaryPom;
209+
if ( !Boolean.TRUE.equals( generatePom ) )
210+
{
211+
pomFile = temporaryPom;
212+
getLog().debug( "Using JAR embedded POM as pomFile" );
213+
}
210214
}
211215

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

323327
if ( pomEntry.matcher( entry.getName() ).matches() )
324328
{
325-
getLog().debug( "Using " + entry.getName() + " as pomFile" );
329+
getLog().debug( "Loading " + entry.getName() );
326330

327331
InputStream pomInputStream = null;
328332
OutputStream pomOutputStream = null;

src/test/java/org/apache/maven/plugins/install/InstallFileMojoTest.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,6 @@ public void testBasicInstallFile()
9292
assignValuesForParameter( mojo );
9393

9494
mojo.execute();
95-
96-
File pomFile = (File) getVariableValueFromObject( mojo, "pomFile" );
97-
org.codehaus.plexus.util.FileUtils.forceDelete( pomFile );
9895

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

123120
mojo.execute();
124121

125-
File pomFile = (File) getVariableValueFromObject( mojo, "pomFile" );
126-
org.codehaus.plexus.util.FileUtils.forceDelete( pomFile );
127-
128122
File installedArtifact = new File( getBasedir(), LOCAL_REPO + groupId + "/" + artifactId + "/" + version + "/" +
129123
artifactId + "-" + version + "-" + classifier + "." + packaging );
130124

0 commit comments

Comments
 (0)