Results 1 to 2 of 2
- 01-13-2013, 09:15 AM #1
Building an executable jar, then using it to generate source
Project A produces an executable jar artifact that generates Java source from XML files specified on the command line. So far so good.
Now I want project B to run A's artifact (building it if necessary) in B's process-resources phase to generate some of B's source. How do I do that?
My Google-fu is weak tonight...Get in the habit of using standard Java naming conventions!
- 01-15-2013, 02:41 AM #2
Re: Building an executable jar, then using it to generate source
It may not be ideal, but this is how I did it: exec-maven-plugin runs my custom build tool in the generate-sources phase and registers its source output directory as a Maven source directory. Then build-helper-maven-plugin registers the tool's resource output directory as a Maven resource directory. All the generated stuff is under target so it gets cleaned automatically.
Java Code:<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.github.kjkrum</groupId> <artifactId>JTX</artifactId> <version>1.0</version> <name>Java Terminal eXtreme</name> <description>A fast and flexible Swing terminal system</description> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.6</version> <scope>test</scope> </dependency> <dependency> <groupId>com.github.kjkrum</groupId> <artifactId>Automaton</artifactId> <version>1.12</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <executions> <execution> <id>jplex-build</id> <phase>generate-sources</phase> <goals> <goal>java</goal> </goals> </execution> </executions> <configuration> <mainClass>krum.jplex.JPlex</mainClass> <arguments> <argument>${basedir}/src/main/jplex/DemoLexer.jplex</argument> <argument>${project.build.directory}/generated-sources/jplex/</argument> <argument>${project.build.directory}/generated-resources/jplex/</argument> </arguments> <sourceRoot>${project.build.directory}/generated-sources/jplex/</sourceRoot> <includePluginDependencies>true</includePluginDependencies> </configuration> <dependencies> <dependency> <groupId>com.github.kjkrum</groupId> <artifactId>JPlex</artifactId> <version>1.1</version> </dependency> </dependencies> </plugin> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>build-helper-maven-plugin</artifactId> <executions> <execution> <id>add-resource</id> <phase>generate-resources</phase> <goals> <goal>add-resource</goal> </goals> <configuration> <resources> <resource> <directory>${project.build.directory}/generated-resources/jplex/</directory> </resource> </resources> </configuration> </execution> </executions> </plugin> <plugin> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.5</source> <target>1.5</target> </configuration> </plugin> </plugins> </build> </project>Get in the habit of using standard Java naming conventions!
Similar Threads
-
Generate UML2 from source
By Flipper in forum EclipseReplies: 2Last Post: 08-01-2012, 02:52 PM -
create windows executable using executable jar file
By sarwar1234 in forum New To JavaReplies: 2Last Post: 02-07-2011, 08:29 PM -
Same source file but different source folders for different build configurations?
By m3anman in forum EclipseReplies: 0Last Post: 01-29-2009, 10:43 AM -
MavenJava - browse source code of all open source projects online
By jirkacelak in forum Java SoftwareReplies: 1Last Post: 11-28-2008, 06:27 PM -
Generate an executable file
By romina in forum New To JavaReplies: 1Last Post: 08-07-2007, 05:30 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks