FELIX-352: provide informational error message when manifest goal is run before compile phase
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@574500 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/bundleplugin/src/main/java/org/apache/felix/bundleplugin/ManifestPlugin.java b/bundleplugin/src/main/java/org/apache/felix/bundleplugin/ManifestPlugin.java
index 52abd17..4a67c24 100644
--- a/bundleplugin/src/main/java/org/apache/felix/bundleplugin/ManifestPlugin.java
+++ b/bundleplugin/src/main/java/org/apache/felix/bundleplugin/ManifestPlugin.java
@@ -19,6 +19,7 @@
package org.apache.felix.bundleplugin;
import java.io.File;
+import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.HashMap;
@@ -57,6 +58,10 @@
{
manifest = this.getManifest( project, instructions, properties, classpath );
}
+ catch ( FileNotFoundException e )
+ {
+ throw new MojoExecutionException( "Cannot find " + e.getMessage() + " (manifest goal must be run after compile phase)", e );
+ }
catch ( IOException e )
{
throw new MojoExecutionException( "Error trying to generate Manifest", e );
@@ -112,17 +117,16 @@
File file = project.getArtifact().getFile();
if ( file == null )
{
- analyzer.setJar( this.getOutputDirectory() );
+ file = getOutputDirectory();
}
- else
+
+ if ( !file.exists() )
{
- if ( !file.exists() )
- {
- file.mkdirs();
- }
- analyzer.setJar( project.getArtifact().getFile() );
+ throw new FileNotFoundException( file.getPath() );
}
+ analyzer.setJar( file );
+
if ( classpath != null )
analyzer.setClasspath( classpath );
diff --git a/bundleplugin/src/test/java/org/apache/felix/bundleplugin/BundleAllPluginTest.java b/bundleplugin/src/test/java/org/apache/felix/bundleplugin/BundleAllPluginTest.java
index 9eaeb63..11e9c40 100644
--- a/bundleplugin/src/test/java/org/apache/felix/bundleplugin/BundleAllPluginTest.java
+++ b/bundleplugin/src/test/java/org/apache/felix/bundleplugin/BundleAllPluginTest.java
@@ -24,7 +24,6 @@
import java.util.Collections;
import java.util.Map;
-import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.testing.stubs.ArtifactStub;
import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
import org.apache.maven.project.MavenProject;