You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by re...@apache.org on 2013/02/25 23:06:42 UTC
svn commit: r1449921 -
/uima/sandbox/uimafit/trunk/uimafit-maven-plugin/src/main/java/org/apache/uima/fit/maven/GenerateDescriptorsMojo.java
Author: rec
Date: Mon Feb 25 22:06:42 2013
New Revision: 1449921
URL: http://svn.apache.org/r1449921
Log:
[UIMA-2598] uimaFIT meta data file pointing to the location of XML descriptors
https://issues.apache.org/jira/browse/UIMA-2598
- write META-INF/org.apache.uima.fit/components.txt unless option to skip is set
Modified:
uima/sandbox/uimafit/trunk/uimafit-maven-plugin/src/main/java/org/apache/uima/fit/maven/GenerateDescriptorsMojo.java
Modified: uima/sandbox/uimafit/trunk/uimafit-maven-plugin/src/main/java/org/apache/uima/fit/maven/GenerateDescriptorsMojo.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uimafit/trunk/uimafit-maven-plugin/src/main/java/org/apache/uima/fit/maven/GenerateDescriptorsMojo.java?rev=1449921&r1=1449920&r2=1449921&view=diff
==============================================================================
--- uima/sandbox/uimafit/trunk/uimafit-maven-plugin/src/main/java/org/apache/uima/fit/maven/GenerateDescriptorsMojo.java (original)
+++ uima/sandbox/uimafit/trunk/uimafit-maven-plugin/src/main/java/org/apache/uima/fit/maven/GenerateDescriptorsMojo.java Mon Feb 25 22:06:42 2013
@@ -25,6 +25,7 @@ import java.io.OutputStream;
import java.lang.reflect.Modifier;
import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang.exception.ExceptionUtils;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.Component;
@@ -64,6 +65,18 @@ public class GenerateDescriptorsMojo ext
@Parameter(defaultValue="${project.build.directory}/generated-sources/uimafit", required=true)
private File outputDirectory;
+ /**
+ * Skip generation of META-INF/org.apache.uima.fit/components.txt
+ */
+ @Parameter(defaultValue = "false", required = true)
+ private boolean skipComponentsManifest;
+
+ /**
+ * Source file encoding.
+ */
+ @Parameter(defaultValue = "${project.build.sourceEncoding}", required = true)
+ private String encoding;
+
public void execute() throws MojoExecutionException {
// add the generated sources to the build
if (!outputDirectory.exists()) {
@@ -78,6 +91,9 @@ public class GenerateDescriptorsMojo ext
componentLoader = Util.getClassloader(project, getLog());
+ // List of components that is later written to META-INF/org.apache.uima.fit/components.txt
+ StringBuilder componentsManifest = new StringBuilder();
+
for (String file : files) {
String base = file.substring(0, file.length() - 6);
String clazzPath = base.substring(project.getBuild().getOutputDirectory().length() + 1);
@@ -105,6 +121,9 @@ public class GenerateDescriptorsMojo ext
File out = new File(outputDirectory, clazzPath+".xml");
out.getParentFile().mkdirs();
toXML(desc, out.getPath());
+
+ // Remember component
+ componentsManifest.append("classpath*:").append(clazzPath+".xml").append('\n');
}
} catch (SAXException e) {
getLog().warn("Cannot serialize descriptor for [" + clazzName + "]", e);
@@ -116,6 +135,18 @@ public class GenerateDescriptorsMojo ext
getLog().warn("Cannot generate descriptor for [" + clazzName + "]", e);
}
}
+
+ // Write META-INF/org.apache.uima.fit/components.txt
+ if (!skipComponentsManifest) {
+ File path = new File(outputDirectory, "META-INF/org.apache.uima.fit/components.txt");
+ FileUtils.mkdir(path.getParent());
+ try {
+ FileUtils.fileWrite(path.getPath(), encoding, componentsManifest.toString());
+ } catch (IOException e) {
+ throw new MojoExecutionException("Cannot write components manifest to [" + path + "]"
+ + ExceptionUtils.getRootCauseMessage(e), e);
+ }
+ }
}
/**