Author: pderop
Date: Tue Jan 12 13:05:09 2010
New Revision: 898309
URL: http://svn.apache.org/viewvc?rev=898309&view=rev
Log:
Fixed logging. Don't generate temporary file from /tmp. Fixed bug: the target
bundle was not deleted before copy
Modified:
felix/trunk/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/plugin/mvn/AnnotationMojo.java
Modified:
felix/trunk/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/plugin/mvn/AnnotationMojo.java
URL:
http://svn.apache.org/viewvc/felix/trunk/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/plugin/mvn/AnnotationMojo.java?rev=898309&r1=898308&r2=898309&view=diff
==============================================================================
---
felix/trunk/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/plugin/mvn/AnnotationMojo.java
(original)
+++
felix/trunk/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/plugin/mvn/AnnotationMojo.java
Tue Jan 12 13:05:09 2010
@@ -19,6 +19,7 @@
package org.apache.felix.dm.annotation.plugin.mvn;
import java.io.File;
+import java.io.IOException;
import java.util.Iterator;
import java.util.Map;
@@ -98,10 +99,7 @@
{
jar.putResource(entry.getKey(), entry.getValue());
}
- output = File.createTempFile(getClass().getName(),
m_artifactExtension);
- jar.write(output);
- jar.close();
- output.renameTo(target);
+ copy(jar, target);
}
// Check if some errors have to be logged.
@@ -119,7 +117,7 @@
{
for (Iterator<String> e = analyzer.getWarnings().iterator();
e.hasNext();)
{
- getLog().warn(e.next());
+ getLog().info(e.next());
}
}
}
@@ -139,7 +137,7 @@
{
if (output != null && output.exists())
{
- output.delete();
+ //output.delete();
}
if (jar != null)
@@ -159,4 +157,37 @@
return new File(build.getDirectory() + File.separator +
build.getFinalName() + "."
+ m_artifactExtension);
}
+
+ /**
+ * Copy the generated jar into our target bundle.
+ * @param jar the jar with the generated component descriptors
+ * @param target our target bundle
+ * @throws MojoExecutionException on any errors
+ * @throws Exception on any error
+ */
+ private void copy(Jar jar, File target) throws MojoExecutionException,
Exception
+ {
+ File tmp = new File(getBundleName() + ".tmp");
+ try
+ {
+ if (tmp.exists())
+ {
+ if (! tmp.delete()) {
+ throw new MojoExecutionException("Could not remove " +
tmp);
+ }
+ }
+ jar.write(tmp);
+ jar.close();
+
+ if (!tmp.renameTo(target))
+ {
+ throw new MojoExecutionException("Could not rename " + tmp + "
to " + target);
+ }
+ }
+ finally
+ {
+ jar.close();
+ tmp.delete();
+ }
+ }
}
\ No newline at end of file