You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by ewhauser <ew...@gmail.com> on 2007/12/14 16:51:18 UTC

Resolving snapshot filenames from Mojo

Hi,

I wrote a Mojo that generates a wrapper.conf file for installing ActiveMQ as
a service.  One of the things it generates is the class path:

wrapper.java.classpath.1=../lib/wrapper.jar
wrapper.java.classpath.2=../lib/activemq-all-5.0-SNAPSHOT.jar
wrapper.java.classpath.3=../lib/activemq-core-5.0-SNAPSHOT.jar
wrapper.java.classpath.4=../lib/commons-logging-api-1.1.jar
wrapper.java.classpath.5=../lib/camel-core-1.2.0.jar
...

This works for except when using the assembly:assembly command, the files
are archived as their actual snapshot filename (i.e.
activeio-core-3.1-20071214.010031-268.jar,
activemq-core-5.0-20071208.031023-17.jar).  I am retrieving the classpath
references by looping over MavenProject#getRuntimeArtifacts and calling
Artifact#getFile#getName.

I am trying to figure out how to get the true snapshot filename, so so it
matches what is bundled through the assembly plugin.  Any help would be
appreciated.

Thanks.
-- 
View this message in context: http://www.nabble.com/Resolving-snapshot-filenames-from-Mojo-tp14338324s177p14338324.html
Sent from the Maven - Users mailing list archive at Nabble.com.


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


Re: Resolving snapshot filenames from Mojo

Posted by ewhauser <ew...@gmail.com>.
I ended up stealing some of the code from the Assembly plugin.  However,
there are a couple of dependencies that it was still always resolving
incorrectly.  I believe that there may be someone incorrect with the pom's
for these projects that is causing the issue:

[WARNING] Attempting to build MavenProject instance for Artifact
(org.apache.camel:camel-core:1.3-20071212.032026-32) of type: jar;
constructing POM artifact instead.
[WARNING] Attempting to build MavenProject instance for Artifact
(org.apache.activemq:activeio-core:3.1-20071217.010134-271) of type:
test-jar; constructing POM artifact instead.
[WARNING] Attempting to build MavenProject instance for Artifact
(org.apache.camel:camel-http:1.3-20071212.032026-30) of type: jar;
constructing POM artifact instead.
[WARNING] Attempting to build MavenProject instance for Artifact
(org.apache.commons:commons-io:1.3.2) of type: jar; constructing POM
artifact instead.

Regardless, I found a workaround for my scenario.  Thnaks for the help.
-- 
View this message in context: http://www.nabble.com/Resolving-snapshot-filenames-from-Mojo-tp14338324s177p14399267.html
Sent from the Maven - Users mailing list archive at Nabble.com.


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


Re: Resolving snapshot filenames from Mojo

Posted by Stuart McCulloch <st...@jayway.net>.
On 14/12/2007, ewhauser <ew...@gmail.com> wrote:
>
>
> Hi,
>
> I wrote a Mojo that generates a wrapper.conf file for installing ActiveMQ
> as
> a service.  One of the things it generates is the class path:
>
> wrapper.java.classpath.1=../lib/wrapper.jar
> wrapper.java.classpath.2=../lib/activemq-all-5.0-SNAPSHOT.jar
> wrapper.java.classpath.3=../lib/activemq-core-5.0-SNAPSHOT.jar
> wrapper.java.classpath.4=../lib/commons-logging-api-1.1.jar
> wrapper.java.classpath.5=../lib/camel-core-1.2.0.jar
> ...
>
> This works for except when using the assembly:assembly command, the files
> are archived as their actual snapshot filename (i.e.
> activeio-core-3.1-20071214.010031-268.jar,
> activemq-core-5.0-20071208.031023-17.jar).  I am retrieving the classpath
> references by looping over MavenProject#getRuntimeArtifacts and calling
> Artifact#getFile#getName.
>
> I am trying to figure out how to get the true snapshot filename, so so it
> matches what is bundled through the assembly plugin.  Any help would be
> appreciated.


you could get the SNAPSHOT version (without the build timestamp) by using:

        if( artifact.isSnapshot() ) {
            try {
                return artifact.getSelectedVersion().toString();
            }
            catch( Exception e ) {
                // fall thru
            }
        }

        return artifact.getVersion();

and then use this with other artifact methods to reconstruct the right
name... (ie. artifactId-version.type)

or, if you inject the local repository parameter:

    /**
     * The local Maven repository.
     *
     * @parameter expression="${localRepository}"
     * @required
     * @readonly
     */
    private ArtifactRepository localRepository;

then you could use localRepository.pathOf(artifact) which I think will also
include the non-timestamp version
( you'd just need to trim off the leading path to get the base filename )

HTH

Thanks.
> --
> View this message in context:
> http://www.nabble.com/Resolving-snapshot-filenames-from-Mojo-tp14338324s177p14338324.html
> Sent from the Maven - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>


-- 
Cheers, Stuart