[MINSTALL-110] install-file should also install bundled pom.xml from artifact.
Follow-up: make sure the POM file extracted from the archive is into a temporary folder, and that it is correctly deleted after installation.
git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk@1770444 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/it/minstall-55/verify.bsh b/src/it/minstall-55/verify.bsh
index 6180188..fb8984f 100644
--- a/src/it/minstall-55/verify.bsh
+++ b/src/it/minstall-55/verify.bsh
@@ -37,4 +37,10 @@
}
}
+File file = new File( basedir, "test-0.1.pom" );
+if ( !file.isFile() )
+{
+ throw new FileNotFoundException( "Missing: " + file.getAbsolutePath() );
+}
+
return true;
diff --git a/src/main/java/org/apache/maven/plugin/install/InstallFileMojo.java b/src/main/java/org/apache/maven/plugin/install/InstallFileMojo.java
index d7d6f9f..efff979 100644
--- a/src/main/java/org/apache/maven/plugin/install/InstallFileMojo.java
+++ b/src/main/java/org/apache/maven/plugin/install/InstallFileMojo.java
@@ -213,13 +213,16 @@
getLog().debug( "localRepoPath: " + repositoryManager.getLocalRepositoryBasedir( buildingRequest ) );
}
+ File temporaryPom = null;
+
if ( pomFile != null )
{
processModel( readModel( pomFile ) );
}
else
{
- readingPomFromJarFile();
+ temporaryPom = readingPomFromJarFile();
+ pomFile = temporaryPom;
}
validateArtifactInformation();
@@ -261,8 +264,8 @@
}
else
{
- File generatedPomFile = generatePomFile();
- ProjectArtifactMetadata pomMetadata = new ProjectArtifactMetadata( artifact, generatedPomFile );
+ temporaryPom = generatePomFile();
+ ProjectArtifactMetadata pomMetadata = new ProjectArtifactMetadata( artifact, temporaryPom );
if ( Boolean.TRUE.equals( generatePom )
|| ( generatePom == null && !getLocalRepoFile( buildingRequest, pomMetadata ).exists() ) )
{
@@ -273,7 +276,7 @@
}
else
{
- project.setFile( generatedPomFile );
+ project.setFile( temporaryPom );
}
}
else if ( generatePom == null )
@@ -306,6 +309,14 @@
{
throw new MojoExecutionException( e.getMessage(), e );
}
+ finally
+ {
+ if ( temporaryPom != null )
+ {
+ // noinspection ResultOfMethodCallIgnored
+ temporaryPom.delete();
+ }
+ }
}
/**
@@ -336,10 +347,10 @@
}
}
- private void readingPomFromJarFile()
+ private File readingPomFromJarFile()
throws MojoExecutionException
{
- boolean foundPom = false;
+ File pomFile = null;
JarFile jarFile = null;
try
@@ -358,8 +369,6 @@
{
getLog().debug( "Using " + entry.getName() + " as pomFile" );
- foundPom = true;
-
InputStream pomInputStream = null;
OutputStream pomOutputStream = null;
@@ -372,7 +381,7 @@
{
base = base.substring( 0, base.lastIndexOf( '.' ) );
}
- pomFile = new File( file.getParentFile(), base + ".pom" );
+ pomFile = File.createTempFile( base, ".pom" );
pomOutputStream = new FileOutputStream( pomFile );
@@ -396,7 +405,7 @@
}
}
- if ( !foundPom )
+ if ( pomFile == null )
{
getLog().info( "pom.xml not found in " + file.getName() );
}
@@ -419,6 +428,7 @@
}
}
}
+ return pomFile;
}
/**