You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by Kris Bravo <kr...@corridor-software.us> on 2005/07/08 07:29:41 UTC

[M2]NullPointerException on getCompileClasspathElements()

I have the following handle to the MavenProject defined in a plugin
written for maven 2.

   /**
    * The project whose project files to create.
    *
    * @parameter expression="${project}"
    * @required
    */
   private MavenProject project;

When I attempt to get the list of classpath elements, i.e.,

project.getCompileClasspathElements()

I receive a null pointer exception due to a call to
getArtifacts().size();

java.lang.NullPointerException
        at
org.apache.maven.project.MavenProject.getCompileClasspathElements(MavenProject.java:282)
        at
org.apache.maven.plugin.xmlbeans.XmlBeansPlugin.getClasspath(XmlBeansPlugin.java:271)
        at
org.apache.maven.plugin.xmlbeans.ParameterAdapter.getCompilerParameters(ParameterAdapter.java:31)
        at
org.apache.maven.plugin.xmlbeans.XmlBeansPlugin.execute(XmlBeansPlugin.java:203)
        at
org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:401)
        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:169)
        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:143)

Is there another way to retrieve a List of the classpath elements used
by the java compiler during a build? Also, the debug lists elements
(calls them constituents) in the classpath, but doesn't include those
defined in the dependencies section of the pom.

Am I barking up the wrong tree?

Kris 




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


Re: [M2]NullPointerException on getCompileClasspathElements()

Posted by Vincent Siveton <vi...@gmail.com>.
Already added in jira:
http://jira.codehaus.org/browse/MNG-556

Cheers,

Vincent

2005/7/8, Kris Bravo <kr...@corridor-software.us>:
> Thanks Kenney, that fixed the problem. At the same time, it would be
> helpful if the error explained this nuance.
> 
> Before I add to Jira, can we assume that MavenProject.getArtifacts()
> should *never* return null for a valid project with resolved
> dependencies? If so, the method could throw an
> DependencyResolutionRequiredException instead:
> 
> "Dependencies have not been resolved. If this is a plugin, verify that
> @requiresDependencyResolution is set in the mojo object. See the
> developer's documentation for more detail."
> 
> Thoughts?
> 
> Kris
> 
> On Fri, 2005-07-08 at 09:29 +0200, Kenney Westerhof wrote:
> > On Fri, 8 Jul 2005, Kris Bravo wrote:
> >
> > You should define
> >
> >  @requiresDependencyResolution compile
> >
> > in the class-level javadoc.
> >
> > > I have the following handle to the MavenProject defined in a plugin
> > > written for maven 2.
> > >
> > >    /**
> > >     * The project whose project files to create.
> > >     *
> > >     * @parameter expression="${project}"
> > >     * @required
> > >     */
> > >    private MavenProject project;
> > >
> > > When I attempt to get the list of classpath elements, i.e.,
> > >
> > > project.getCompileClasspathElements()
> > >
> > > I receive a null pointer exception due to a call to
> > > getArtifacts().size();
> > >
> > > java.lang.NullPointerException
> > >         at
> > > org.apache.maven.project.MavenProject.getCompileClasspathElements(MavenProject.java:282)
> > >         at
> > > org.apache.maven.plugin.xmlbeans.XmlBeansPlugin.getClasspath(XmlBeansPlugin.java:271)
> > >         at
> > > org.apache.maven.plugin.xmlbeans.ParameterAdapter.getCompilerParameters(ParameterAdapter.java:31)
> > >         at
> > > org.apache.maven.plugin.xmlbeans.XmlBeansPlugin.execute(XmlBeansPlugin.java:203)
> > >         at
> > > org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:401)
> > >         at
> > > org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:169)
> > >         at
> > > org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:143)
> > >
> > > Is there another way to retrieve a List of the classpath elements used
> > > by the java compiler during a build? Also, the debug lists elements
> > > (calls them constituents) in the classpath, but doesn't include those
> > > defined in the dependencies section of the pom.
> > >
> > > Am I barking up the wrong tree?
> > >
> > > Kris
> > >
> > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> > > For additional commands, e-mail: dev-help@maven.apache.org
> > >
> >
> > --
> > Kenney Westerhof
> > http://www.neonics.com
> > GPG public key: http://www.gods.nl/~forge/kenneyw.key
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> > For additional commands, e-mail: dev-help@maven.apache.org
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
> 
>

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


Re: [M2]NullPointerException on getCompileClasspathElements()

Posted by Kris Bravo <kr...@corridor-software.us>.
Thanks Kenney, that fixed the problem. At the same time, it would be
helpful if the error explained this nuance.

Before I add to Jira, can we assume that MavenProject.getArtifacts()
should *never* return null for a valid project with resolved
dependencies? If so, the method could throw an
DependencyResolutionRequiredException instead:

"Dependencies have not been resolved. If this is a plugin, verify that
@requiresDependencyResolution is set in the mojo object. See the
developer's documentation for more detail."

Thoughts?

Kris

On Fri, 2005-07-08 at 09:29 +0200, Kenney Westerhof wrote: 
> On Fri, 8 Jul 2005, Kris Bravo wrote:
> 
> You should define
> 
>  @requiresDependencyResolution compile
> 
> in the class-level javadoc.
> 
> > I have the following handle to the MavenProject defined in a plugin
> > written for maven 2.
> >
> >    /**
> >     * The project whose project files to create.
> >     *
> >     * @parameter expression="${project}"
> >     * @required
> >     */
> >    private MavenProject project;
> >
> > When I attempt to get the list of classpath elements, i.e.,
> >
> > project.getCompileClasspathElements()
> >
> > I receive a null pointer exception due to a call to
> > getArtifacts().size();
> >
> > java.lang.NullPointerException
> >         at
> > org.apache.maven.project.MavenProject.getCompileClasspathElements(MavenProject.java:282)
> >         at
> > org.apache.maven.plugin.xmlbeans.XmlBeansPlugin.getClasspath(XmlBeansPlugin.java:271)
> >         at
> > org.apache.maven.plugin.xmlbeans.ParameterAdapter.getCompilerParameters(ParameterAdapter.java:31)
> >         at
> > org.apache.maven.plugin.xmlbeans.XmlBeansPlugin.execute(XmlBeansPlugin.java:203)
> >         at
> > org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:401)
> >         at
> > org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:169)
> >         at
> > org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:143)
> >
> > Is there another way to retrieve a List of the classpath elements used
> > by the java compiler during a build? Also, the debug lists elements
> > (calls them constituents) in the classpath, but doesn't include those
> > defined in the dependencies section of the pom.
> >
> > Am I barking up the wrong tree?
> >
> > Kris
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> > For additional commands, e-mail: dev-help@maven.apache.org
> >
> 
> --
> Kenney Westerhof
> http://www.neonics.com
> GPG public key: http://www.gods.nl/~forge/kenneyw.key
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
> 


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


Re: [M2]NullPointerException on getCompileClasspathElements()

Posted by Kenney Westerhof <fo...@neonics.com>.
On Fri, 8 Jul 2005, Kris Bravo wrote:

You should define

 @requiresDependencyResolution compile

in the class-level javadoc.

> I have the following handle to the MavenProject defined in a plugin
> written for maven 2.
>
>    /**
>     * The project whose project files to create.
>     *
>     * @parameter expression="${project}"
>     * @required
>     */
>    private MavenProject project;
>
> When I attempt to get the list of classpath elements, i.e.,
>
> project.getCompileClasspathElements()
>
> I receive a null pointer exception due to a call to
> getArtifacts().size();
>
> java.lang.NullPointerException
>         at
> org.apache.maven.project.MavenProject.getCompileClasspathElements(MavenProject.java:282)
>         at
> org.apache.maven.plugin.xmlbeans.XmlBeansPlugin.getClasspath(XmlBeansPlugin.java:271)
>         at
> org.apache.maven.plugin.xmlbeans.ParameterAdapter.getCompilerParameters(ParameterAdapter.java:31)
>         at
> org.apache.maven.plugin.xmlbeans.XmlBeansPlugin.execute(XmlBeansPlugin.java:203)
>         at
> org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:401)
>         at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:169)
>         at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:143)
>
> Is there another way to retrieve a List of the classpath elements used
> by the java compiler during a build? Also, the debug lists elements
> (calls them constituents) in the classpath, but doesn't include those
> defined in the dependencies section of the pom.
>
> Am I barking up the wrong tree?
>
> Kris
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
>

--
Kenney Westerhof
http://www.neonics.com
GPG public key: http://www.gods.nl/~forge/kenneyw.key

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