You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by christo <ch...@think.net.au> on 2008/05/16 02:36:06 UTC

Maven 1 classes in my plugin JAR not on runtime classpath?

Hi All,

I've read the docs, googled, read mailing list archives, asked in irc
etc. but have been unable to find the answer to this.

I'm writing a maven 1 plugin which adds a goal that calls <ant:java>
running the main method of a class which is bundled in the plugin jar.
There are jar deps in the plugin but my question is not about ensuring
that the plugin's dependencies are on the runtime classpath of the
jvm. I understand how to do this using the
${plugin.getDependencyPath()} call.

The purpose of the plugin is to create a file for the distribution -
essentially metadata for the app. Originally I tried to implement the
whole thing in Jelly but after a few hours I gave up and wrote it in a
dozen lines of Java.

The plugin runs the goal in my project but when the jvm tries to load
my class it can't find it. Why is the plugin jar not on the classpath
of the project when the goal is sought? I have tried sprinkling magic
fork="true" spawn="true" and this doesn't work.

I've been assuming I need to put a classpath reference into the
<ant:java> tag.  But I can't do this because my plugin jar is not  a
dep of itself. Below you can see I've descended into cargo culting a
bit in frustration and pasted ant path elements willy nilly.

The only other plugins I can find that bundle classes are build
reports which register themselves explicitly. Do I have to register
for a non report plugin?

My plugin id: maven-hash-registry-plugin
Main class for plugin: com.atlassian.hashregistry.GenerateHashRegistry
Goal name: hashregistry:generate

<project xmlns:ant="jelly:ant">
  <goal name="hashregistry:generate" prereqs="java:compile"
description="Generate the hash registry">
    <ant:java classname="com.atlassian.hashregistry.GenerateHashRegistry">
        <ant:classpath>
                <ant:pathelement location="${maven.build.dest}" />
                <ant:path refid="maven.dependency.classpath" />
                <ant:path refid="maven.compile.src.set" />
                <ant:pathelement
location="${plugin.getDependencyPath('commons-jelly:commons-jelly')}"/>
                <ant:pathelement
location="${plugin.getDependencyPath('commons-codec:commons-codec')}"/>
                <ant:pathelement
location="${plugin.getDependencyPath('commons-io:commons-io')}"/>
                <ant:pathelement
location="${plugin.getDependencyPath('maven-hash-registry-plugin:maven-hash-registry-plugin')}"/>
                <ant:pathelement
location="${plugin.getDependencyPath('maven-hash-registry-plugin')}"/>
<!-- just in case this is correct -->
           </ant:classpath>
    </ant:java>
  </goal>
</project>

Any pointers or wisdom would help. I'm just about to check out the
source to Maven!

thanks in advance,

Chris.

-- 
Chris Mountford

"In theory, there is no difference between theory and practice. But,
in practice, there is." -- Jan L. A. van de Snepscheut

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Maven 1 classes in my plugin JAR not on runtime classpath?

Posted by christo <ch...@think.net.au>.
Hi Lukas,

Thanks very much for this information. I did run with -X and saw the
classpath but expected that the plugin jar would be on the classpath
within a goal defined by that plugin.

I'll extract my stuff into a separate jar.

Chris.

2008/5/16 Lukas Theussl <lt...@apache.org>:
> IIRC artifacts of type plugin are not added to the runtime classpath (if you
> run with -X you should see a corresponding message). You have to
> deploy/install the plugin as a jar and declare a dependency of a jar type.
>
> HTH,
> -Lukas
>
>
> christo wrote:
>>
>> Hi All,
>>
>> I've read the docs, googled, read mailing list archives, asked in irc
>> etc. but have been unable to find the answer to this.
>>
>> I'm writing a maven 1 plugin which adds a goal that calls <ant:java>
>> running the main method of a class which is bundled in the plugin jar.
>> There are jar deps in the plugin but my question is not about ensuring
>> that the plugin's dependencies are on the runtime classpath of the
>> jvm. I understand how to do this using the
>> ${plugin.getDependencyPath()} call.
>>
>> The purpose of the plugin is to create a file for the distribution -
>> essentially metadata for the app. Originally I tried to implement the
>> whole thing in Jelly but after a few hours I gave up and wrote it in a
>> dozen lines of Java.
>>
>> The plugin runs the goal in my project but when the jvm tries to load
>> my class it can't find it. Why is the plugin jar not on the classpath
>> of the project when the goal is sought? I have tried sprinkling magic
>> fork="true" spawn="true" and this doesn't work.
>>
>> I've been assuming I need to put a classpath reference into the
>> <ant:java> tag.  But I can't do this because my plugin jar is not  a
>> dep of itself. Below you can see I've descended into cargo culting a
>> bit in frustration and pasted ant path elements willy nilly.
>>
>> The only other plugins I can find that bundle classes are build
>> reports which register themselves explicitly. Do I have to register
>> for a non report plugin?
>>
>> My plugin id: maven-hash-registry-plugin
>> Main class for plugin: com.atlassian.hashregistry.GenerateHashRegistry
>> Goal name: hashregistry:generate
>>
>> <project xmlns:ant="jelly:ant">
>>  <goal name="hashregistry:generate" prereqs="java:compile"
>> description="Generate the hash registry">
>>    <ant:java classname="com.atlassian.hashregistry.GenerateHashRegistry">
>>        <ant:classpath>
>>                <ant:pathelement location="${maven.build.dest}" />
>>                <ant:path refid="maven.dependency.classpath" />
>>                <ant:path refid="maven.compile.src.set" />
>>                <ant:pathelement
>> location="${plugin.getDependencyPath('commons-jelly:commons-jelly')}"/>
>>                <ant:pathelement
>> location="${plugin.getDependencyPath('commons-codec:commons-codec')}"/>
>>                <ant:pathelement
>> location="${plugin.getDependencyPath('commons-io:commons-io')}"/>
>>                <ant:pathelement
>>
>> location="${plugin.getDependencyPath('maven-hash-registry-plugin:maven-hash-registry-plugin')}"/>
>>                <ant:pathelement
>> location="${plugin.getDependencyPath('maven-hash-registry-plugin')}"/>
>> <!-- just in case this is correct -->
>>           </ant:classpath>
>>    </ant:java>
>>  </goal>
>> </project>
>>
>> Any pointers or wisdom would help. I'm just about to check out the
>> source to Maven!
>>
>> thanks in advance,
>>
>> Chris.
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>



-- 
Chris Mountford

"In theory, there is no difference between theory and practice. But,
in practice, there is." -- Jan L. A. van de Snepscheut

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Maven 1 classes in my plugin JAR not on runtime classpath?

Posted by Lukas Theussl <lt...@apache.org>.
IIRC artifacts of type plugin are not added to the runtime classpath (if 
you run with -X you should see a corresponding message). You have to 
deploy/install the plugin as a jar and declare a dependency of a jar type.

HTH,
-Lukas


christo wrote:
> Hi All,
> 
> I've read the docs, googled, read mailing list archives, asked in irc
> etc. but have been unable to find the answer to this.
> 
> I'm writing a maven 1 plugin which adds a goal that calls <ant:java>
> running the main method of a class which is bundled in the plugin jar.
> There are jar deps in the plugin but my question is not about ensuring
> that the plugin's dependencies are on the runtime classpath of the
> jvm. I understand how to do this using the
> ${plugin.getDependencyPath()} call.
> 
> The purpose of the plugin is to create a file for the distribution -
> essentially metadata for the app. Originally I tried to implement the
> whole thing in Jelly but after a few hours I gave up and wrote it in a
> dozen lines of Java.
> 
> The plugin runs the goal in my project but when the jvm tries to load
> my class it can't find it. Why is the plugin jar not on the classpath
> of the project when the goal is sought? I have tried sprinkling magic
> fork="true" spawn="true" and this doesn't work.
> 
> I've been assuming I need to put a classpath reference into the
> <ant:java> tag.  But I can't do this because my plugin jar is not  a
> dep of itself. Below you can see I've descended into cargo culting a
> bit in frustration and pasted ant path elements willy nilly.
> 
> The only other plugins I can find that bundle classes are build
> reports which register themselves explicitly. Do I have to register
> for a non report plugin?
> 
> My plugin id: maven-hash-registry-plugin
> Main class for plugin: com.atlassian.hashregistry.GenerateHashRegistry
> Goal name: hashregistry:generate
> 
> <project xmlns:ant="jelly:ant">
>   <goal name="hashregistry:generate" prereqs="java:compile"
> description="Generate the hash registry">
>     <ant:java classname="com.atlassian.hashregistry.GenerateHashRegistry">
>         <ant:classpath>
>                 <ant:pathelement location="${maven.build.dest}" />
>                 <ant:path refid="maven.dependency.classpath" />
>                 <ant:path refid="maven.compile.src.set" />
>                 <ant:pathelement
> location="${plugin.getDependencyPath('commons-jelly:commons-jelly')}"/>
>                 <ant:pathelement
> location="${plugin.getDependencyPath('commons-codec:commons-codec')}"/>
>                 <ant:pathelement
> location="${plugin.getDependencyPath('commons-io:commons-io')}"/>
>                 <ant:pathelement
> location="${plugin.getDependencyPath('maven-hash-registry-plugin:maven-hash-registry-plugin')}"/>
>                 <ant:pathelement
> location="${plugin.getDependencyPath('maven-hash-registry-plugin')}"/>
> <!-- just in case this is correct -->
>            </ant:classpath>
>     </ant:java>
>   </goal>
> </project>
> 
> Any pointers or wisdom would help. I'm just about to check out the
> source to Maven!
> 
> thanks in advance,
> 
> Chris.
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org