Bill, The ${project.compileClasspathElements} value was a test setting. You can specify any value you like.
Martin -----Oorspronkelijk bericht----- Van: Bill Yang [mailto:[EMAIL PROTECTED] Verzonden: maandag 20 februari 2006 20:54 Aan: Maven Users List Onderwerp: RE: {M2.0.2] refer maven.dependency.classpath in developing ant plugin (mojo) Martin, Thanks for the help. I tested your anttask, I found when I set the expression ${project.compileClasspathElements}, the returned path just contains ${basedir}\target\classes, but without including all dependencies. I checked antrun plugin, it is using the method getCompileClasspathElements() to get path, which includes all dependencies classpath. Is there anything wrong or missing with my setting? my Mojo is: <mojo> <goal>get-classpath</goal> <call>get-classpath</call> <description>get classpath</description> <parameter> <name>classpath</name> <required>true</required> <readonly>true</readonly> <expression>${project.compileClasspathElements}</expression> <description>classpath</description> </parameter> </mojo> my Ant script is: <target name="get-classpath"> <echo>Try to get the classpath</echo> <taskdef resource="comtasks.properties"/> <listtopath sourceref="classpath" targetref="compile.classpath"/> <pathconvert property="echo.compile.classpath" refid="compile.classpath"/> <echo message="classpath=${echo.compile.classpath}"/> </target> Thanks. Bill -----Original Message----- From: Martin van der Plas [mailto:[EMAIL PROTECTED] Sent: Monday, February 20, 2006 10:16 AM To: Maven Users List Subject: Re: {M2.0.2] refer maven.dependency.classpath in developing ant plugin (mojo) Bill, I've sent the anttask code to your mail adress . Your mojo configuration looks ok (by eyeball inspection). The default expression of each parameter is ${name}. defaultValue will be used when expression evaluates to null. So as long as you don't configure ${name} on the mvn command line or in the plugin configuration, defaultValue is used. The parameter is marked readonly and required so I prefer to use expression to set is value. I don't want users to override this value to make the build reproduceable. Martin Bill Yang wrote: >Martin, > >Thanks a lot. > >It will very appreciated if you can send your anttask me. > >btw, you said, I need to define a path as a readonly parameter >of type java.util.List and set expression to ${maven.project.classpath}, >is it "expression" tag, or "defaultValue" tag. >I guess the mojo should me like this, > <mojo> > <goal>get-classpath</goal> > <call>get-classpath</call> > <description>get classpath</description> > <parameters> > <parameter> > <name>dependencyclasspath</name> > <property>dependencyclasspath</property> > <required>true</required> > <readonly>true</readonly> > > <defaultValue>${maven.project.classpath}</defaultValue> > <type>java.util.List</type> > <description>maven dependency > classpath.</description> > </parameter> > </parameters> > </mojo> > >is that right? > >Regards, > >Bill > >-----Original Message----- >From: Martin van der Plas [mailto:[EMAIL PROTECTED] >Sent: Monday, February 20, 2006 4:11 AM >To: Maven Users List >Subject: Re: {M2.0.2] refer maven.dependency.classpath in developing ant >plugin (mojo) > > >Bill, > >See http://www.nabble.com/forum/ViewPost.jtp?post=2661163&framed=y. >The classpaths are not available to the ant project by default. You need >to define a path as a readonly parameter of type java.util.List and set >expression to e.g ${maven.project.testClasspath}. >Since the parameter is not a String, it is added to the projects as a >reference, with key name equal to the parameter name. >Then, you need an anttask to convert the list into a path. > >I've the anttask code available, also sent it to John Casey but got no >reply yet. I can give you the code in case you are interested. > >Martin > >Bill Yang wrote: > > > >>Hello, >> >>Thanks to the guide, >>http://maven.apache.org/guides/plugin/guide-ant-plugin-development.html >>I have successfully developed some simple ant plugin. but when I run an ant >>script to refer the maven classpath, I got >> >> >>[ERROR] BUILD ERROR >>[INFO] >>-------------------------------------------------------------------------- - >> >> >- > > >>[INFO] Failed to execute: Executing Ant script: /test.build.xml >>[get-classpath]: Failed to execute. >> >>Reference maven.dependency.classpath not found.. >> >> >> >>even I tried use a parameter with >> <defaultValue>${project.runtimeClasspathElements}</defaultValue> >> <type>java.util.Set</type> >> >>I am using maven 2.0.2, Here is the source: >> >>test.build.xml >><project> >> <target name="get-classpath"> >> <echo>Try to get the classpath</echo> >> <property name="out" refid="maven.dependency.classpath" /> >> <echo>out: ${out}</echo> >> </target> >></project> >> >>test.mojo.xml >><mojo> >> <goal>get-classpath</goal> >> <call>get-classpath</call> >> <description>get classpath</description> >></mojo> >> >>in the plugin pom.xml, do have following configuration: >> <artifactId>maven-plugin-plugin</artifactId> >> <dependencies> >> <dependency> >> <groupId>org.apache.maven</groupId> >> <artifactId>maven-plugin-tools-ant</artifactId> >> <version>2.0.1</version> >> </dependency> >> </dependencies> >> >>btw, from the link >>http://www.nabble.com/Support-for-mojos-written-in-Ant-t863193.html#a23422 9 >> >> >0 > > >>seems we don't need to manually add any "maven.dependency.classpath" refids >>to ANT, >>that already happens behind the scenes. But why can't my ant script get >>that reference? >> >>Thanks in advance. >> >>Bill >> >> >> >> >> >> >>------------------------------------------------------------------------ >> >>--------------------------------------------------------------------- >>To unsubscribe, e-mail: [EMAIL PROTECTED] >>For additional commands, e-mail: [EMAIL PROTECTED] >> >> >> > > >--------------------------------------------------------------------- >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] > > > > > >--------------------------------------------------------------------- >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] > > > -- Groeten, Martin mailto:[EMAIL PROTECTED] tel: +31 (0) 20-7988464 mob: +31 (0) 6-21551921 --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.1.375 / Virus Database: 267.15.11/264 - Release Date: 17-02-2006 -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.375 / Virus Database: 267.15.11/264 - Release Date: 17-02-2006 --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]