Re: custom maven plugin - how to determine current project module?
MG>not obvious see below From: Bear Giles Sent: Thursday, October 4, 2018 5:13 PM To: Maven Users List Subject: Q: custom maven plugin - how to determine current project module? This is probably mindnumbingly obvious and my google and SO skills are horrible but here goes I'm working on a complex project with multiple tiers of modules. In some cases I want to build one module, plus its dependencies (-am), and upload it to a server via a REST call. I didn't have a problem writing the maven plugin with a hard-coded path. Or I'll want to build several related modules and upload all of them. I want to be able to upload a path relative to the module I'm building. I haven't written a plug-in to dump all system properties and environment variables yet so it's probably something as simple as, the pom.xml properties, e.g., $project.name, also being available as system properties. But it's not documented and I'm paranoid about things that aren't documented since they often change without warning. So: 1. is that the case? 2. is there a reason the "write a custom maven plugin" pages don't mention it early and often, at least on the page that discusses how to get information from your custom plugin's configuration stanza? ... a related question. If one plugin sets a system property, e.g., that 'buildId' I mentioned earlier, will it be visible to all of the other maven plugins during that run? Even if the build is multi-threaded? MG>starting with maven 3 you can request n-number thread allocation per cpu-core directive in maven https://cwiki.apache.org/confluence/display/MAVEN/Parallel+builds+in+Maven+3 Parallel builds in Maven 3 - Apache Maven - Apache ...<https://cwiki.apache.org/confluence/display/MAVEN/Parallel+builds+in+Maven+3> Maven 3.x has the capability to perform parallel builds. The command is as follows: mvn -T 4 clean install # Builds with 4 threads mvn -T 1C clean install # 1 thread per cpu core mvn -T 1.5C clean install # 1.5 thread per cpu core. This build-mode analyzes your project's dependency graph and schedules modules that can be built in parallel according to the dependency graph of your project. cwiki.apache.org In this case there would be one custom plugin that generates the build id and uploads the artifact but it would set a value that could then be used by other plugins during the build. Basically a -Dname=value, but doing it via a plugin instead of the command line. MG>from what little you have shared i believe maven-resources-plugin (resources:resources) will handle property MG>manipulation https://maven.apache.org/plugins/maven-resources-plugin/resources-mojo.html Apache Maven Resources Plugin – resources:resources<https://maven.apache.org/plugins/maven-resources-plugin/resources-mojo.html> Copy resources for the main source code to the main output directory. Always uses the project.build.resources element to specify the resources to copy. maven.apache.org MG>keep in mind these implementations are classloader-dependent MG>not such a big deal with launch but later plugin invocations may use their own classloaders MG>so your forked classloader *eg surefire-plugin* may not see maven classloader properties MG>unless you configure SystemPropertyVariables for that plugin http://maven.apache.org/surefire/maven-surefire-plugin/examples/system-properties.html Maven Surefire Plugin – Using System Properties<http://maven.apache.org/surefire/maven-surefire-plugin/examples/system-properties.html> The string ${project.build.outputDirectory} will be passed on literally because the type of that expression is a File, not a String.. To inherit the systemProperties collection from the parent configuration, you will need to specify combine.children="append" on the systemProperties node in the child pom: maven.apache.org Thanks, Bear
Q: custom maven plugin - how to determine current project module?
This is probably mindnumbingly obvious and my google and SO skills are horrible but here goes I'm working on a complex project with multiple tiers of modules. In some cases I want to build one module, plus its dependencies (-am), and upload it to a server via a REST call. I didn't have a problem writing the maven plugin with a hard-coded path. Or I'll want to build several related modules and upload all of them. I want to be able to upload a path relative to the module I'm building. I haven't written a plug-in to dump all system properties and environment variables yet so it's probably something as simple as, the pom.xml properties, e.g., $project.name, also being available as system properties. But it's not documented and I'm paranoid about things that aren't documented since they often change without warning. So: 1. is that the case? 2. is there a reason the "write a custom maven plugin" pages don't mention it early and often, at least on the page that discusses how to get information from your custom plugin's configuration stanza? ... a related question. If one plugin sets a system property, e.g., that 'buildId' I mentioned earlier, will it be visible to all of the other maven plugins during that run? Even if the build is multi-threaded? In this case there would be one custom plugin that generates the build id and uploads the artifact but it would set a value that could then be used by other plugins during the build. Basically a -Dname=value, but doing it via a plugin instead of the command line. Thanks, Bear
RE: Classpath issue in custom maven plugin
From: mgai...@hotmail.com To: users@maven.apache.org Subject: RE: Classpath issue in custom maven plugin Date: Mon, 15 Sep 2014 18:49:41 -0400 Date: Mon, 15 Sep 2014 19:06:56 +0530 Subject: Classpath issue in custom maven plugin From: kavita.gpt1...@gmail.com To: users@maven.apache.org CC: shailesh.man...@gmail.com Hi! I have created my own custom maven plugin(api-docs) for developing apiary blueprint. While triggering my custom plugin using m2Eclipse I am getting a classpath issue that classPath.getresources is fetching resources from plexus jar, while when I debug the swagger plugin (which I am taking as a reference) it is picking up the resources from rt.jar. In swagger I am getting web/target/classes in URLS but in my custom project I am not getting the web/target/classes in URLS. Code snippet is: MG>as previously mentioned... If the tests pass on command line with maven 3.0.2 or newer but fail from m2e, please open a bugreport in https://bugs.eclipse.org/bugs/enter_bug.cgi?product=m2e Make sure to attach complete standalone example project and steps to reproduce the problem. https://docs.sonatype.org/display/M2ECLIPSE/Runtime+classpath MG> ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); System.out.println(classLoader.getResources("com/abc/service/rest/resource")); assert classLoader != null;String path = packageName.replace('.', '/');Enumeration resources = classLoader.getResources(path); My custom plugin's dependency tree is attached(apidocsTree.txt). I have integrated it in my other project i.e web. Here is the web pom configuration for the plugin. com.thed api-docs 1.0-SNAPSHOT com.thed.service.rest.resource apiary.vm ${basedir}/target/apiary.apib prepare-package generateApiDocs I am taking swagger-plugin as a reference. Its dependency tree is attached as swaggerTree.txt. Its configuration in web is: com.github.kongchen swagger-maven-plugin 1.0-SNAPSHOT com.thed.service.rest.resource v1 http://localhost:8080/flex/services/rest/latest ${basedir}/src/site/docs/template/rest/zephyr_html.mustache ${basedir}/src/main/webapp/data/rest-doc.html prepare-package generate Please provide me the input to solve this classpath issue. -- Thanks, Kavita Gupta Agarwal - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org
RE: Classpath issue in custom maven plugin
Date: Mon, 15 Sep 2014 19:06:56 +0530 Subject: Classpath issue in custom maven plugin From: kavita.gpt1...@gmail.com To: users@maven.apache.org CC: shailesh.man...@gmail.com Hi! I have created my own custom maven plugin(api-docs) for developing apiary blueprint. While triggering my custom plugin using m2Eclipse I am getting a classpath issue that classPath.getresources is fetching resources from plexus jar, while when I debug the swagger plugin (which I am taking as a reference) it is picking up the resources from rt.jar. In swagger I am getting web/target/classes in URLS but in my custom project I am not getting the web/target/classes in URLS. Code snippet is:MG> ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); System.out.println(classLoader.getResources("com/abc/service/rest/resource")); assert classLoader != null;String path = packageName.replace('.', '/');Enumeration resources = classLoader.getResources(path); My custom plugin's dependency tree is attached(apidocsTree.txt). I have integrated it in my other project i.e web. Here is the web pom configuration for the plugin. com.thed api-docs 1.0-SNAPSHOT com.thed.service.rest.resource apiary.vm ${basedir}/target/apiary.apib prepare-package generateApiDocs I am taking swagger-plugin as a reference. Its dependency tree is attached as swaggerTree.txt. Its configuration in web is: com.github.kongchen swagger-maven-plugin 1.0-SNAPSHOT com.thed.service.rest.resource v1 http://localhost:8080/flex/services/rest/latest ${basedir}/src/site/docs/template/rest/zephyr_html.mustache ${basedir}/src/main/webapp/data/rest-doc.html prepare-package generate Please provide me the input to solve this classpath issue. -- Thanks, Kavita Gupta Agarwal - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org
Re: Classpath issue in custom maven plugin
Limitation perhaps comes from OSGi where each bundle has its own class loader. Did u try to run it from command line? On Sep 15, 2014 6:36 AM, "Kavita Gupta" wrote: > > Hi! > > I have created my own custom maven plugin(api-docs) for developing apiary > blueprint. While triggering my custom plugin using m2Eclipse I am getting a > classpath issue that classPath.getresources is fetching resources from > plexus jar, while when I debug the swagger plugin (which I am taking as a > reference) it is picking up the resources from rt.jar. In swagger I am > getting web/target/classes in URLS but in my custom project I am not > getting the web/target/classes in URLS. Code snippet is: > > ClassLoader classLoader = > Thread.currentThread().getContextClassLoader(); > > > System.out.println(classLoader.getResources("com/abc/service/rest/resource")); > > assert classLoader != null; > > String path = packageName.replace('.', '/'); > > Enumeration resources = classLoader.getResources(path); > > > My custom plugin's dependency tree is attached(apidocsTree.txt). I have > integrated it in my other project i.e web. Here is the web pom > configuration for the plugin. > > > > com.thed > > api-docs > > 1.0-SNAPSHOT > > > > com.thed.service.rest.resource > > apiary.vm > > > ${basedir}/target/apiary.apib > > > > > > > > prepare-package > > > > generateApiDocs > > > > > > > > > > > > I am taking swagger-plugin as a reference. Its dependency tree is attached > as swaggerTree.txt. Its configuration in web is: > > > >com.github.kongchen > >swagger-maven-plugin > >1.0-SNAPSHOT > > > > > > > >com.thed.service.rest.resource > >v1 > >http://localhost:8080/flex/services/rest/latest > > > > > ${basedir}/src/site/docs/template/rest/zephyr_html.mustache > > > ${basedir}/src/main/webapp/data/rest-doc.html > > > > > > > > > > > >prepare-package > > > > generate > > > > > > > > > > > Please provide me the input to solve this classpath issue. > > > -- > Thanks, > Kavita Gupta Agarwal >
Classpath issue in custom maven plugin
Hi! I have created my own custom maven plugin(api-docs) for developing apiary blueprint. While triggering my custom plugin using m2Eclipse I am getting a classpath issue that classPath.getresources is fetching resources from plexus jar, while when I debug the swagger plugin (which I am taking as a reference) it is picking up the resources from rt.jar. In swagger I am getting web/target/classes in URLS but in my custom project I am not getting the web/target/classes in URLS. Code snippet is: ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); System.out.println(classLoader.getResources("com/abc/service/rest/resource")); assert classLoader != null; String path = packageName.replace('.', '/'); Enumeration resources = classLoader.getResources(path); My custom plugin's dependency tree is attached(apidocsTree.txt). I have integrated it in my other project i.e web. Here is the web pom configuration for the plugin. com.thed api-docs 1.0-SNAPSHOT com.thed.service.rest.resource apiary.vm ${basedir}/target/apiary.apib prepare-package generateApiDocs I am taking swagger-plugin as a reference. Its dependency tree is attached as swaggerTree.txt. Its configuration in web is: com.github.kongchen swagger-maven-plugin 1.0-SNAPSHOT com.thed.service.rest.resource v1 http://localhost:8080/flex/services/rest/latest ${basedir}/src/site/docs/template/rest/zephyr_html.mustache ${basedir}/src/main/webapp/data/rest-doc.html prepare-package generate Please provide me the input to solve this classpath issue. -- Thanks, Kavita Gupta Agarwal [INFO] Scanning for projects... [INFO] [INFO] [INFO] Building api-docs Maven Plugin 1.0-SNAPSHOT [INFO] [INFO] [INFO] --- maven-dependency-plugin:2.1:tree (default-cli) @ api-docs --- [INFO] com.thed:api-docs:maven-plugin:1.0-SNAPSHOT [INFO] +- org.apache.maven:maven-artifact:jar:2.2.1:compile [INFO] | \- org.codehaus.plexus:plexus-utils:jar:1.5.15:compile [INFO] +- org.apache.maven:maven-plugin-api:jar:2.2.1:compile [INFO] +- org.apache.maven:maven-project:jar:2.2.1:compile [INFO] | +- org.apache.maven:maven-settings:jar:2.2.1:compile [INFO] | +- org.apache.maven:maven-profile:jar:2.2.1:compile [INFO] | +- org.apache.maven:maven-artifact-manager:jar:2.2.1:compile [INFO] | | \- backport-util-concurrent:backport-util-concurrent:jar:3.1:compile [INFO] | +- org.apache.maven:maven-plugin-registry:jar:2.2.1:compile [INFO] | +- org.codehaus.plexus:plexus-interpolation:jar:1.11:compile [INFO] | \- org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-9-stable-1:compile [INFO] +- org.apache.maven:maven-model:jar:2.2.1:compile [INFO] +- org.apache.maven:maven-core:jar:2.0.9:compile [INFO] | +- org.apache.maven.wagon:wagon-file:jar:1.0-beta-2:runtime [INFO] | +- org.apache.maven:maven-plugin-parameter-documenter:jar:2.0.9:compile [INFO] | +- org.apache.maven.wagon:wagon-webdav:jar:1.0-beta-2:runtime [INFO] | | \- slide:slide-webdavlib:jar:2.1:runtime [INFO] | | +- commons-httpclient:commons-httpclient:jar:2.0.2:runtime [INFO] | | +- jdom:jdom:jar:1.0:runtime [INFO] | | \- de.zeigermann.xml:xml-im-exporter:jar:1.1:runtime [INFO] | +- org.apache.maven.wagon:wagon-http-lightweight:jar:1.0-beta-2:runtime [INFO] | | \- org.apache.maven.wagon:wagon-http-shared:jar:1.0-beta-2:runtime [INFO] | | \- jtidy:jtidy:jar:4aug2000r7-dev:runtime [INFO] | +- org.apache.maven.reporting:maven-reporting-api:jar:2.0.9:compile [INFO] | | \- org.apache.maven.doxia:doxia-sink-api:jar:1.0-alpha-10:compile [INFO] | +- org.apache.maven.wagon:wagon-provider-api:jar:1.0-beta-2:compile [INFO] | +- org.apache.maven:maven-repository-metadata:jar:2.0.9:compile [INFO] | +- org.apache.maven:maven-error-diagnostics:jar:2.0.9:compile [INFO] | +- commons-cli:commons-cli:jar:1.0:compile [INFO] | +- org.apache.maven.wagon:wagon-ssh-external:jar:1.0-beta-2:runtime [INFO] | | \- org.apache.maven.wagon:wagon-ssh-common:jar:1.0-beta-2:runtime [INFO] | +- org.apache.maven:maven-plugin-descriptor:jar:2.0.9:compile [INFO] | +- org.codehaus.plexus:plexus-interactivity-api:jar:1.0-alpha-4:compile [INFO] | +- org.apache.maven:maven-monitor:jar:2.0.9:compile [INFO] | +- org.apache.maven.wagon:wagon-ssh:jar:1.0-beta-2:runtime [INFO] | | \- com.jcraft:jsch:jar:0.1.27:runtime [INFO] |
Re: Custom maven plugin to count compilation warnings
Yes, you're right here that IDE is a good place to check for warnings. However, we have a requirement for a Maven plugin which accepts a predefined number of warnings in code (Java/Scala, legacy code which we aren't going to rewrite anytime soon due to the lack of time) and checks that no more warnings were introduced since last commit. The ideas I have in mind: 1) Custom plugin that makes calls to Java/Scala compilers and checks the code for warnings. 2) Modified maven-compiler-plugin and maven-scala-plugin which can store warnings and pass them to the custom plugin. 3) Custom plugin parse Maven output log looking for warnings. -- View this message in context: http://maven.40175.n5.nabble.com/Custom-maven-plugin-to-count-compilation-warnings-tp5787921p5788093.html Sent from the Maven - Users mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org
Re: Custom maven plugin to count compilation warnings
Would it not be a better use of time to get rid of the warnings? Your IDE should point out which code includes warnings and should warn you when you try to check-in code that has warnings. Ron On 11/03/2014 9:28 AM, yk wrote: Hi, I'm trying to write a plugin for Maven that would count the number of compiler warnings and act in some way if that number is not what it is expected to be. The question is how a custom Maven plugin could find out the number of warnings/errors compiler produces? -- View this message in context: http://maven.40175.n5.nabble.com/Custom-maven-plugin-to-count-compilation-warnings-tp5787921.html Sent from the Maven - Users mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org -- Ron Wheeler President Artifact Software Inc email: rwhee...@artifact-software.com skype: ronaldmwheeler phone: 866-970-2435, ext 102 - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org
Custom maven plugin to count compilation warnings
Hi, I'm trying to write a plugin for Maven that would count the number of compiler warnings and act in some way if that number is not what it is expected to be. The question is how a custom Maven plugin could find out the number of warnings/errors compiler produces? -- View this message in context: http://maven.40175.n5.nabble.com/Custom-maven-plugin-to-count-compilation-warnings-tp5787921.html Sent from the Maven - Users mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org
Antwort: Re: Re: Custom Maven Plugin
Hey, thanks a lot! That solved my problems! Mit freundlichen Grüßen / Best regards Jan Engler Central Research & Development SICK AG Erwin-Sick-Str. 1 79183 Waldkirch, Germany Phone +49 7681 202-3214 mailto:jan.eng...@sick.de http://www.sick.com Von:Thomas Broyer An: Maven Users List Datum: 18.03.2013 14:28 Betreff:Re: Re: Custom Maven Plugin Try project.getCompileClasspathElements(), it resolves transitive dependencies and gives you their location as absolute file names. http://maven.apache.org/ref/3.0.5/maven-core/apidocs/org/apache/maven/project/MavenProject.html#getCompileClasspathElements() On Mon, Mar 18, 2013 at 2:22 PM, Jan Engler wrote: > Ok, > > I am adapting the jni4net maven plugin (see > https://code.google.com/p/jni4net/) to fit our needs. In short, this > plugin collects a set of classes with the intention to generate .net > wrapper for. Furthermore, the tool that create those wrappers > (proxygen.exe) needs the complete dependecies as 'classpath' argument. It > works so far, but beneath the direct dependencies of the maven project my > plugin is running on, I also need the transitive dependencies. All the > information about that is passed to the proxygen.exe using an xml file... > In the case of a dependency that is described by a workspace resolution I > would like to pass a jar > I tried your hint with @requiresDependencyResolution compile but that > didn't work. Here is a snippet of my code: > > /** > * @requiresDependencyResolution compile > * @goal proxygen > * > * @phase process-sources > */ > public class ProxygenMojo extends AbstractMojo { > /** > * @parameter expression="${proxygen.exe}" > * @required > */ > private File exe; > > /** @parameter expression="${proxygen.xml}" default- > value="proxygen.xml" */ > private File xml; > /** @parameter expression="${proxygen.bin}" default- > value="target/classes" */ > private String bin; > > /** > * @parameter > */ > private List artifacts; > /** > * @parameter > */ > private List classes; > > /** > * @parameter expression="${proxygen.targetDirJvm}" > *default-value="java" > */ > String targetDirJvm; > > /** > * @parameter expression="${proxygen.targetDirClr}" > * default-value="csharp" > */ > String targetDirClr; > > /** @parameter default-value="${project}" */ > MavenProject project; > > @SuppressWarnings("unchecked") > public void execute() throws MojoExecutionException { > if (artifacts == null) > artifacts = Collections.emptyList(); > > getLog().info("exe = " + exe.getPath()); > > String jarPath; > ArrayList classPathList = null; > ArrayList classList = null; > > Set artifactSet = project > .getDependencyArtifacts(); > project.getDependencies(); > for (Artifact artifact : artifactSet) { > try { > JarFile depFile = new > JarFile(artifact.getFile()); > if (classPathList == null) { > classPathList = new > ArrayList(); > } > classPathList.add(depFile.getName()); > } catch (IOException e1) { > > e1.printStackTrace(); > } > jarPath = null; > > getLog().info("artifact " + > artifact.getFile().getPath()); > } > > StringBuilder xmlBuilder = new StringBuilder( > " ?>"); > xmlBuilder > .append("\n http://jni4net.sf.net/0.8.0.0/toolConfig.xsd\";>\n"); > xmlBuilder.append("\n").append(targetDirJvm) > .append(""); > xmlBuilder.append("\n").append(targetDirClr) > .append("\n"); > > if (classPathList == null) { > getLog().warn("no artifacts found"); > } else { >
Re: Re: Custom Maven Plugin
xmlBuilder.append('\n'); > } > for (String clazzAsString : classes) { > if (classList == null) { > classList = new ArrayList(); > } > classList.add(clazzAsString); > } > if (classList == null) { > getLog().warn("no classes found"); > } else { > for (String className : classList) { > xmlBuilder.append("\n TypeName=\"" + className > + "\"/>"); > } > } > xmlBuilder.append("\n\n\n"); > > > Any ideas? > > Mit freundlichen Grüßen / Best regards > > Jan Engler > Central Research & Development > > SICK AG > Erwin-Sick-Str. 1 > 79183 Waldkirch, Germany > > Phone +49 7681 202-3214 > mailto:jan.eng...@sick.de > http://www.sick.com > > > > > > Von:Stephen Connolly > An: Maven Users List > Datum: 18.03.2013 14:05 > Betreff:Re: Custom Maven Plugin > > > > I would start by describing what you want to do and why. That way we can > determine if you approach fits best with "the maven way" and suggest the > best way to align with that... There are some alarm bells ringing > > On Monday, 18 March 2013, Jan Engler wrote: > >> Hi, >> >> I am writing my first custom plugin for maven. >> I`m now facing 2 problem. >> - I need to know the absolute location of every dependency (incl. >> transitive deps) > > You need @requiresDependencyResolution in the java doc annotations or the > equivalent (on a phone so cannot look up) for java 1.5 annotations > > >> - Is there a solution for workspace dependencies (i would like to have a >> "jar" of them as well) like "disable workspace resolution" as a method >> call in the plugin? > > > Here is the alarm bell FYI > >> >> Thx in advance! >> Jan >> >> Mit freundlichen Grüßen / Best regards >> >> Jan Engler >> Central Research & Development >> >> SICK AG >> Erwin-Sick-Str. 1 >> 79183 Waldkirch, Germany >> >> Phone +49 7681 202-3214 >> mailto:jan.eng...@sick.de >> http://www.sick.com >> >> >> >> SICK AG - Sitz: Waldkirch i. Br. - Handelsregister: Freiburg i. Br. HRB >> 280355 >> Vorstand: Dr. Robert Bauer (Vorsitzender) - Reinhard Bösl - Dr. > Martin >> Krämer - Markus Paschmann - Markus Vatter >> Aufsichtsrat: Gisela Sick (Ehrenvorsitzende) - Klaus M. Bukenberger >> (Vorsitzender) >> > > > -- > Sent from my phone > > > > SICK AG - Sitz: Waldkirch i. Br. - Handelsregister: Freiburg i. Br. HRB > 280355 > Vorstand: Dr. Robert Bauer (Vorsitzender) - Reinhard Bösl - Dr. Martin > Krämer - Markus Paschmann - Markus Vatter > Aufsichtsrat: Gisela Sick (Ehrenvorsitzende) - Klaus M. Bukenberger > (Vorsitzender) -- Thomas Broyer /tɔ.ma.bʁwa.je/ - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org
Antwort: Re: Custom Maven Plugin
Ok, I am adapting the jni4net maven plugin (see https://code.google.com/p/jni4net/) to fit our needs. In short, this plugin collects a set of classes with the intention to generate .net wrapper for. Furthermore, the tool that create those wrappers (proxygen.exe) needs the complete dependecies as 'classpath' argument. It works so far, but beneath the direct dependencies of the maven project my plugin is running on, I also need the transitive dependencies. All the information about that is passed to the proxygen.exe using an xml file... In the case of a dependency that is described by a workspace resolution I would like to pass a jar I tried your hint with @requiresDependencyResolution compile but that didn't work. Here is a snippet of my code: /** * @requiresDependencyResolution compile * @goal proxygen * * @phase process-sources */ public class ProxygenMojo extends AbstractMojo { /** * @parameter expression="${proxygen.exe}" * @required */ private File exe; /** @parameter expression="${proxygen.xml}" default- value="proxygen.xml" */ private File xml; /** @parameter expression="${proxygen.bin}" default- value="target/classes" */ private String bin; /** * @parameter */ private List artifacts; /** * @parameter */ private List classes; /** * @parameter expression="${proxygen.targetDirJvm}" *default-value="java" */ String targetDirJvm; /** * @parameter expression="${proxygen.targetDirClr}" *default-value="csharp" */ String targetDirClr; /** @parameter default-value="${project}" */ MavenProject project; @SuppressWarnings("unchecked") public void execute() throws MojoExecutionException { if (artifacts == null) artifacts = Collections.emptyList(); getLog().info("exe = " + exe.getPath()); String jarPath; ArrayList classPathList = null; ArrayList classList = null; Set artifactSet = project .getDependencyArtifacts(); project.getDependencies(); for (Artifact artifact : artifactSet) { try { JarFile depFile = new JarFile(artifact.getFile()); if (classPathList == null) { classPathList = new ArrayList(); } classPathList.add(depFile.getName()); } catch (IOException e1) { e1.printStackTrace(); } jarPath = null; getLog().info("artifact " + artifact.getFile().getPath()); } StringBuilder xmlBuilder = new StringBuilder( ""); xmlBuilder .append("\nhttp://jni4net.sf.net/0.8.0.0/toolConfig.xsd\";>\n"); xmlBuilder.append("\n").append(targetDirJvm) .append(""); xmlBuilder.append("\n").append(targetDirClr) .append("\n"); if (classPathList == null) { getLog().warn("no artifacts found"); } else { for (String artifact : classPathList) { xmlBuilder.append("\n"); } xmlBuilder.append("\n"); xmlBuilder.append('\n'); } for (String clazzAsString : classes) { if (classList == null) { classList = new ArrayList(); } classList.add(clazzAsString); } if (classList == null) { getLog().warn("no classes found"); } else { for (String className : classList) { xmlBuilder.append("\n"); } } xmlBuilder.append("\n\n\n"); Any ideas? Mit freundlichen Grüßen / Best regards Jan Engler Central Research & Development SICK AG Erwin-Sick-Str. 1 79183 Waldkirch, Germany Phone +49 7681 202-3214 mailto:jan.eng...@sick.de http://www.sick.com Von:Stephen Connolly An: Maven Users Li
Re: Custom Maven Plugin
I would start by describing what you want to do and why. That way we can determine if you approach fits best with "the maven way" and suggest the best way to align with that... There are some alarm bells ringing On Monday, 18 March 2013, Jan Engler wrote: > Hi, > > I am writing my first custom plugin for maven. > I`m now facing 2 problem. > - I need to know the absolute location of every dependency (incl. > transitive deps) You need @requiresDependencyResolution in the java doc annotations or the equivalent (on a phone so cannot look up) for java 1.5 annotations > - Is there a solution for workspace dependencies (i would like to have a > "jar" of them as well) like "disable workspace resolution" as a method > call in the plugin? Here is the alarm bell FYI > > Thx in advance! > Jan > > Mit freundlichen Grüßen / Best regards > > Jan Engler > Central Research & Development > > SICK AG > Erwin-Sick-Str. 1 > 79183 Waldkirch, Germany > > Phone +49 7681 202-3214 > mailto:jan.eng...@sick.de > http://www.sick.com > > > > SICK AG - Sitz: Waldkirch i. Br. - Handelsregister: Freiburg i. Br. HRB > 280355 > Vorstand: Dr. Robert Bauer (Vorsitzender) - Reinhard Bösl - Dr. Martin > Krämer - Markus Paschmann - Markus Vatter > Aufsichtsrat: Gisela Sick (Ehrenvorsitzende) - Klaus M. Bukenberger > (Vorsitzender) > -- Sent from my phone
Custom Maven Plugin
Hi, I am writing my first custom plugin for maven. I`m now facing 2 problem. - I need to know the absolute location of every dependency (incl. transitive deps) - Is there a solution for workspace dependencies (i would like to have a "jar" of them as well) like "disable workspace resolution" as a method call in the plugin? Thx in advance! Jan Mit freundlichen Grüßen / Best regards Jan Engler Central Research & Development SICK AG Erwin-Sick-Str. 1 79183 Waldkirch, Germany Phone +49 7681 202-3214 mailto:jan.eng...@sick.de http://www.sick.com SICK AG - Sitz: Waldkirch i. Br. - Handelsregister: Freiburg i. Br. HRB 280355 Vorstand: Dr. Robert Bauer (Vorsitzender) - Reinhard Bösl - Dr. Martin Krämer - Markus Paschmann - Markus Vatter Aufsichtsrat: Gisela Sick (Ehrenvorsitzende) - Klaus M. Bukenberger (Vorsitzender)
Re: Custom Maven Plugin Development Archiving Files
> I am developing my own custom Maven plugin and I want to archive the files. I > followd that example: > http://www.sonatype.com/books/mvnref-book/reference/writing-plugins-sect-mojo-params.html > and could archive the elements with zip format. However I want to use other > formats too(user will indicate it) how can I set archive type? Before you spend any (more) time working on a problem that has been solved, look at the assembly plugin and make sure you cannot be made happy using it, perhaps in some combination with your custom plugin that would run in an earlier lifecycle phase, with the assembly plugin responsible for the ultimate output at the end. Wayne - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org
Re: Custom Maven Plugin Development Archiving Files
On 15 February 2013 11:38, kamaci wrote: > I am developing my own custom Maven plugin and I want to archive the files. I > followd that example: > http://www.sonatype.com/books/mvnref-book/reference/writing-plugins-sect-mojo-params.html > and could archive the elements with zip format. However I want to use other > formats too(user will indicate it) how can I set archive type? You could look at the Maven Assembly Plugin (http://maven.apache.org/plugins/maven-assembly-plugin/) which supports creating archives of different types and see how it does it. - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org
Custom Maven Plugin Development Archiving Files
I am developing my own custom Maven plugin and I want to archive the files. I followd that example: http://www.sonatype.com/books/mvnref-book/reference/writing-plugins-sect-mojo-params.html and could archive the elements with zip format. However I want to use other formats too(user will indicate it) how can I set archive type? ZipArchiver works like that: /** * The Zip archiver. * @parameter \ expression="${component.org.codehaus.plexus.archiver.Archiver#zip}" */ private ZipArchiver zipArchiver; ... zipArchiver.addDirectory( buildDirectory, includes, excludes ); zipArchiver.setDestFile( new File( baseDirectory, "output.zip" ) ); zipArchiver.createArchive(); -- View this message in context: http://maven.40175.n5.nabble.com/Custom-Maven-Plugin-Development-Archiving-Files-tp5747036.html Sent from the Maven - Users mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org
Re: Calling a custom maven plugin
Also if you have the plugin configured in your pom (even in pluginManagement) and the goalPrefix (http://maven.apache.org/plugins/maven-plugin-plugin/descriptor-mojo.html#goalPrefix) was correctly configured or auto-detected for your plugin, then you can just use goalPrefix:goal when running maven against that pom.xml 2009/9/25 Anders Hammar : > The way I know of is through the pluginGroups element of settings.xml. > > /Anders > > On Fri, Sep 25, 2009 at 03:12, Tristan Rouse wrote: > >> I'm currently working with the book "Better Builds with Maven" and doing >> some custom maven plugin development. I have a plugin I've created with the >> following POM info. >> >> com.exist.mvnbook.plugins >> > maven-buildinfo-plugin >> > maven-plugin >> > >> >> You know how you can just type "mvn :" for many >> mojos? >> My mojo has to run like this: "mvn >> com.exist.mvnbook.plugins:maven-buildinfo-plugin:extract" >> where "extract" is the mojo name. From the error I get when I try to run it >> like this 'mvn buildinfo:extract" it looks like I could get it to run that >> way if I changed the groupId of my mojo to "org.apache.maven.plugins". It >> seems rather inappropriate to use this groupId myself? Is there another way >> to get my mojo to run without having to be so verbose? >> >> Thanks very much. >> > - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org
Re: Calling a custom maven plugin
The way I know of is through the pluginGroups element of settings.xml. /Anders On Fri, Sep 25, 2009 at 03:12, Tristan Rouse wrote: > I'm currently working with the book "Better Builds with Maven" and doing > some custom maven plugin development. I have a plugin I've created with the > following POM info. > > com.exist.mvnbook.plugins > > maven-buildinfo-plugin > > maven-plugin > > > > You know how you can just type "mvn :" for many > mojos? > My mojo has to run like this: "mvn > com.exist.mvnbook.plugins:maven-buildinfo-plugin:extract" > where "extract" is the mojo name. From the error I get when I try to run it > like this 'mvn buildinfo:extract" it looks like I could get it to run that > way if I changed the groupId of my mojo to "org.apache.maven.plugins". It > seems rather inappropriate to use this groupId myself? Is there another way > to get my mojo to run without having to be so verbose? > > Thanks very much. >
Calling a custom maven plugin
I'm currently working with the book "Better Builds with Maven" and doing some custom maven plugin development. I have a plugin I've created with the following POM info. com.exist.mvnbook.plugins > maven-buildinfo-plugin > maven-plugin > You know how you can just type "mvn :" for many mojos? My mojo has to run like this: "mvn com.exist.mvnbook.plugins:maven-buildinfo-plugin:extract" where "extract" is the mojo name. From the error I get when I try to run it like this 'mvn buildinfo:extract" it looks like I could get it to run that way if I changed the groupId of my mojo to "org.apache.maven.plugins". It seems rather inappropriate to use this groupId myself? Is there another way to get my mojo to run without having to be so verbose? Thanks very much.