Use this method.. it creates a correct classpath string to be used
with the java -cp argument

/**
     * Constructs AspectJ compiler classpath string
     *
     * @return a os spesific classpath string
     */
    protected String createClassPath()
    {
        String cp = new String();
        Set classPathElements = new HashSet();
        classPathElements.addAll(project.getDependencyArtifacts());
        classPathElements.addAll(project.getArtifacts());
        Iterator iter = classPathElements.iterator();
        while ( iter.hasNext() )
        {
            Artifact classPathElement = (Artifact) iter.next();
            File artifact = classPathElement.getFile();
            if ( null != artifact )
            {
                cp += classPathElement.getFile().getAbsolutePath();
                cp += File.pathSeparatorChar;
            }
        }
        cp += getOutputDirectory();

        return cp;
    }


On 04/12/05, Jagan Padmanabha Pillai -X (jpadmana - Insight Solutions,
Inc. at Cisco) <[EMAIL PROTECTED]> wrote:
>
>
> Hi,
> I tried this. All its returning is my project output classes dir
> (target/classes). Why doesn't it have the dependencies mantioned in the
> POM file. I checked the project.getArtifacts() &
> project.getDependencyArtifacts(). These 2 are returning null.
>
> Project.getDependencies is returning an object like this,
> Dependency {groupId=junit, artifactId=junit, version=3.8.1,
> type=jar},Dependency {groupId=org.apache.maven,
> artifactId=maven-project, version=2.0-beta-3, type=jar},
>
> What I am trying to do is,
> To get the classpath from maven and pass it to another command using
> "-classpath" option. I need to have all the dependency jars in this
> classpath.
> Isn't there a easy way to get the classpath var just like $CLASSPATH
>
> Please let me know
>
> Thanks
> -Jagan
>
> -----Original Message-----
> From: Allan Ramirez [mailto:[EMAIL PROTECTED]
> Sent: Friday, December 02, 2005 7:17 PM
> To: Maven Users List
> Subject: Re: Maven2 dependency classpath in Java plugin
>
> Hi there,
>
> I think this is what you are looking for
>
> getCompileClasspathElements()
>
> you can find it in the maven-project component  source.
> org\apache\maven\project\MavenProject.java
>
> Jagan Padmanabha Pillai -X (jpadmana - Insight Solutions, Inc. at Cisco)
> wrote:
>
> >
> >Hi,
> >I am trying to get the mvn dependency classpath inside the plugin
> >written using java.
> >In maven 1 there seems to be a way for ant using
> >{maven.dependency.classpath}.
> >
> >Does anyone know how to get this classpath in maven2 ????
> >
> >Also in org.apache.maven.project.Project seems to have a method
> >getdependecyClassPath(). But I am not sure which jar file is this
> >Project class is in. when I put the above class in import statement its
>
> >erroring out.
> >
> >Please let me know
> >
> >Thanks
> >Jagan
> >
> >
> >
> >
> >
> >-----------------------------------------------------------------------
> >-
> >
> >No virus found in this incoming message.
> >Checked by AVG Free Edition.
> >Version: 7.1.362 / Virus Database: 267.13.11/191 - Release Date:
> >12/2/2005
> >
> >
>
> ---------------------------------------------------------------------
> 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]

  • ... Kaare Nilsen
    • ... Jagan Padmanabha Pillai -X \(jpadmana - Insight Solutions, Inc. at Cisco\)

Reply via email to