If setting the classpathScope to runtime the project classpath is empty
-----------------------------------------------------------------------

                 Key: MEXEC-56
                 URL: http://jira.codehaus.org/browse/MEXEC-56
             Project: Maven 2.x Exec Plugin
          Issue Type: Bug
          Components: exec
    Affects Versions: 1.1
         Environment: Maven 2.0.9, Netbeans 6.1, maven plugin 3.1.4
            Reporter: Mathias Arens


Hello,

I would like to start my Swing GUI from Netbeans 6.1 with maven plugin 3.1.4. 
But my problem is that one dependency is in runtime scope.

So, I set the classpathScope of the exec-maven-plugin to runtime. But then the 
'Collected project classpath' is empty and I get a ClassNotFoundException for 
my main class. In my opinion this is a bug because the 'runtime' scope includes 
all dependencies from the 'compile' scope as well. So it should also contain 
the compiled project classes.

I downloaded the source code and fixed the problem by setting the project 
classpath for the runtime scope in the 
AbstractExecMojo.collectProjectArtifactsAndClasspath(List artifacts, List 
theClasspathFiles) routine:

{code}
protected void collectProjectArtifactsAndClasspath(List artifacts, List 
theClasspathFiles) {

        if ("compile".equals(classpathScope)) {
            artifacts.addAll(project.getCompileArtifacts());
            theClasspathFiles.add(new 
File(project.getBuild().getOutputDirectory()));
        } else if ("test".equals(classpathScope)) {
            artifacts.addAll(project.getTestArtifacts());
            theClasspathFiles.add(new 
File(project.getBuild().getTestOutputDirectory()));
            theClasspathFiles.add(new 
File(project.getBuild().getOutputDirectory()));
        } else if ("runtime".equals(classpathScope)) {
            artifacts.addAll(project.getRuntimeArtifacts());
            theClasspathFiles.add(new 
File(project.getBuild().getOutputDirectory()));
        } else if ("system".equals(classpathScope)) {
            artifacts.addAll(project.getSystemArtifacts());
        } else {
            throw new IllegalStateException("Invalid classpath scope: " + 
classpathScope);
        }

        getLog().debug("Collected project artifacts " + artifacts);
        getLog().debug("Collected project classpath " + theClasspathFiles);
    }
{code}

I just added the 
{code}
theClasspathFiles.add(new File(project.getBuild().getOutputDirectory()));
{code}
to the runtime - code block. Now it works fine. It would be great if this fix 
is included in future releases.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to