Re: Build time classpath using my java plugin
TimHedger wrote: OK, so now I'm using the exec-plugin instead of my own code - great. But I've lost the control I had over when the exec step happened. I am using the plugin to generate SOAP wrappers for some Java code using glue (themindelectric). This step involves running a Java class with certain parameters and it creates various xml files and a directory structure, ready for packing into a war for distribution. My problem is this is happening every time I compile using maven. I've lost any control over checking whether source is stale and thus the soap/exec step if nothing's changed since my last build. How can I get this control with the exec plugin? You can't, the exec plugin does not have that kind of knowledge. I think the best way for you would be to write your own glue plugin that just calls the main() method of the application after setting the system properties. -- Trygve - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Build time classpath using my java plugin
OK, so now I'm using the exec-plugin instead of my own code - great. But I've lost the control I had over when the exec step happened. I am using the plugin to generate SOAP wrappers for some Java code using glue (themindelectric). This step involves running a Java class with certain parameters and it creates various xml files and a directory structure, ready for packing into a war for distribution. My problem is this is happening every time I compile using maven. I've lost any control over checking whether source is stale and thus the soap/exec step if nothing's changed since my last build. How can I get this control with the exec plugin? -- View this message in context: http://www.nabble.com/Build-time-classpath-using-my-java-plugin-tf1914923.html#a5292877 Sent from the Maven - Users forum at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Build time classpath using my java plugin
Doh! (Thank you) -- View this message in context: http://www.nabble.com/Build-time-classpath-using-my-java-plugin-tf1914923.html#a5281234 Sent from the Maven - Users forum at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Build time classpath using my java plugin
replace exec with java TimHedger schrieb: You're right - I did some unnecessary work! (I took my approach from the idlj plugin, that basically puts some wrapper stuff around running the main method on a Java class - I guess that was done that way for convenience rather than needing lots of config in the pom). Anyway, I've dumped my plugin (less code has to be better) and am now using the exec-maven-plugin. And I can get it to do exactly what I need stand alone - by invoking it explicitly: mvn exec:java will run the necessary Java class with all my arguments. But I want to attach this step to a phase so it is nicely included in my build cycle. So I took the approach I have taken with other pugins, but it doesn't seem to work here. Specifics - this is the plugin section of my pom.xml: org.codehaus.mojo exec-maven-plugin glue-processing compile exec true java electric.application.tools.NewApp -Delectric.apphome=target/glue -Delectric.home=/apps/product/glue -h VentureVaRService Here I've tried to attach the exec:java goal to the compile phase. When I invoke mvn exec:java, I get what I expect: : mvn exec:java [INFO] Scanning for projects... [INFO] Searching repository for plugin with prefix: 'exec'. [INFO] [INFO] Building Maven Quick Start Archetype [INFO]task-segment: [exec:java] [INFO] [INFO] Preparing exec:java [INFO] No goals needed for project - skipping [INFO] [exec:java] [DEPLOYMENT] creating application directory at /home/hedgert/maven/venvar/target/glue/VentureVaRService [DEPLOYMENT] copying application files from /apps/product/glue/common [DEPLOYMENT] adding application configuration URLs to config.xml [DEPLOYMENT] saving application configuration file [DEPLOYMENT] application has been successfully created [INFO] [INFO] BUILD SUCCESSFUL [INFO] [INFO] Total time: 8 seconds [INFO] Finished at: Tue Jul 11 18:47:37 BST 2006 [INFO] Final Memory: 3M/8M [INFO] (The DEPLOYMENT lines are the correct output from the Java class I'm running, and this output shows it has taken the arguments I defined in the pom). But if I try to use the compile phase instead: : mvn compile [INFO] Scanning for projects... [INFO] --- [INFO] Building Maven Quick Start Archetype [INFO]task-segment: [compile] [INFO] --- [INFO] [resources:resources] [INFO] Using default encoding to copy filtered resources. [INFO] [compiler:compile] [INFO] No sources to compile [INFO] [exec:exec {execution: glue-processing}] [INFO] Usage: java [-options] class [args...] [INFO](to execute a class) [INFO]or java -jar [-options] jarfile [args...] [INFO](to execute a jar file) [INFO] [INFO] where options include: [INFO] -d32 [INFO] use a 32-bit data model if available [INFO] -d64 [INFO] use a 64-bit data model if available (etc etc) In this case it seems to have invoked the plugin, but it has ignored all my arguments and simply run Java with no parameters. And yet the pom.xml file is unchanged between these two runs. So given the first one (mvn exec:java) works, I guess I'm doing something wrong with the way I'm trying to attach the plugin goal to the compile phase of the build. Can someone point out my mistake? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Build time classpath using my java plugin
You're right - I did some unnecessary work! (I took my approach from the idlj plugin, that basically puts some wrapper stuff around running the main method on a Java class - I guess that was done that way for convenience rather than needing lots of config in the pom). Anyway, I've dumped my plugin (less code has to be better) and am now using the exec-maven-plugin. And I can get it to do exactly what I need stand alone - by invoking it explicitly: mvn exec:java will run the necessary Java class with all my arguments. But I want to attach this step to a phase so it is nicely included in my build cycle. So I took the approach I have taken with other pugins, but it doesn't seem to work here. Specifics - this is the plugin section of my pom.xml: org.codehaus.mojo exec-maven-plugin glue-processing compile exec true java electric.application.tools.NewApp -Delectric.apphome=target/glue -Delectric.home=/apps/product/glue -h VentureVaRService Here I've tried to attach the exec:java goal to the compile phase. When I invoke mvn exec:java, I get what I expect: : mvn exec:java [INFO] Scanning for projects... [INFO] Searching repository for plugin with prefix: 'exec'. [INFO] [INFO] Building Maven Quick Start Archetype [INFO]task-segment: [exec:java] [INFO] [INFO] Preparing exec:java [INFO] No goals needed for project - skipping [INFO] [exec:java] [DEPLOYMENT] creating application directory at /home/hedgert/maven/venvar/target/glue/VentureVaRService [DEPLOYMENT] copying application files from /apps/product/glue/common [DEPLOYMENT] adding application configuration URLs to config.xml [DEPLOYMENT] saving application configuration file [DEPLOYMENT] application has been successfully created [INFO] [INFO] BUILD SUCCESSFUL [INFO] [INFO] Total time: 8 seconds [INFO] Finished at: Tue Jul 11 18:47:37 BST 2006 [INFO] Final Memory: 3M/8M [INFO] (The DEPLOYMENT lines are the correct output from the Java class I'm running, and this output shows it has taken the arguments I defined in the pom). But if I try to use the compile phase instead: : mvn compile [INFO] Scanning for projects... [INFO] --- [INFO] Building Maven Quick Start Archetype [INFO]task-segment: [compile] [INFO] --- [INFO] [resources:resources] [INFO] Using default encoding to copy filtered resources. [INFO] [compiler:compile] [INFO] No sources to compile [INFO] [exec:exec {execution: glue-processing}] [INFO] Usage: java [-options] class [args...] [INFO](to execute a class) [INFO]or java -jar [-options] jarfile [args...] [INFO](to execute a jar file) [INFO] [INFO] where options include: [INFO] -d32 [INFO] use a 32-bit data model if available [INFO] -d64 [INFO] use a 64-bit data model if available (etc etc) In this case it seems to have invoked the plugin, but it has ignored all my arguments and simply run Java with no parameters. And yet the pom.xml file is unchanged between these two runs. So given the first one (mvn exec:java) works, I guess I'm doing something wrong with the way I'm trying to attach the plugin goal to the compile phase of the build. Can someone point out my mistake? -- View this message in context: http://www.nabble.com/Build-time-classpath-using-my-java-plugin-tf1914923.html#a5274398 Sent from the Maven - Users forum at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Build time classpath using my java plugin
TimHedger wrote: I've written a plugin (in Java) that explicitly invokes the main method of a Java class directly from within the jvm that maven is already running. My plugin is behaving/configured as I expect, but I have a classpath problem when control switches from my plugin code to the main method of the Java class it invokes. Seems like you have implemented the exec-maven-plugin [1]. I use the following method to print the classpath before I invoke the main method on my target class: project.getCompileClasspathElements(); (where project is MavenProject) And I get the list of jars I expect, including: /home/hedgert/.m2/repository/javax/servlet/servlet-api/2.4/servlet-api-2.4.jar which is the copy of javax.servlet that I have in my local maven repository. Great - so far so good. I invoke the main method of my target class and the code runs and then falls over with a: java.lang.NoClassDefFoundError: javax/servlet/ServletException If I check the contents of my servlet-api-2.4.jar: : jar -tf /home/hedgert/.m2/repository/javax/servlet/servlet-api/2.4/servlet-api-2.4.jar |grep ServletException javax/servlet/ServletException.class The missing class is indeed in the jar that is on the classpath. So presumably the classpath I'm getting back from: project.getCompileClasspathElements(); is not actually the classpath in operation when I invoke the main method on my class from within a running JVM. So my question is: maven has nicely worked out the classpath I need (using the dependencies in my pom.xml file for my target project, rather than my plugin), how do I get this classpath be active in the running JVM? You don't. The classpath that the plugin is running in contains all dependencies of the plugin, not the project. If you want to do something with the project's classpath you will have to create a classloader from the list you're referring to. [1]: http://mojo.codehaus.org/exec-maven-plugin/ -- Trygve - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Build time classpath using my java plugin
I've written a plugin (in Java) that explicitly invokes the main method of a Java class directly from within the jvm that maven is already running. My plugin is behaving/configured as I expect, but I have a classpath problem when control switches from my plugin code to the main method of the Java class it invokes. I use the following method to print the classpath before I invoke the main method on my target class: project.getCompileClasspathElements(); (where project is MavenProject) And I get the list of jars I expect, including: /home/hedgert/.m2/repository/javax/servlet/servlet-api/2.4/servlet-api-2.4.jar which is the copy of javax.servlet that I have in my local maven repository. Great - so far so good. I invoke the main method of my target class and the code runs and then falls over with a: java.lang.NoClassDefFoundError: javax/servlet/ServletException If I check the contents of my servlet-api-2.4.jar: : jar -tf /home/hedgert/.m2/repository/javax/servlet/servlet-api/2.4/servlet-api-2.4.jar |grep ServletException javax/servlet/ServletException.class The missing class is indeed in the jar that is on the classpath. So presumably the classpath I'm getting back from: project.getCompileClasspathElements(); is not actually the classpath in operation when I invoke the main method on my class from within a running JVM. So my question is: maven has nicely worked out the classpath I need (using the dependencies in my pom.xml file for my target project, rather than my plugin), how do I get this classpath be active in the running JVM? -- View this message in context: http://www.nabble.com/Build-time-classpath-using-my-java-plugin-tf1914923.html#a5242414 Sent from the Maven - Users forum at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]