NetBeans Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
  

Maven with dependency-management

 
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Platform Users
View previous topic :: View next topic  
Author Message
Fabrizio Giudici
Posted via mailing list.





PostPosted: Sat Oct 03, 2009 12:13 pm    Post subject: Maven with dependency-management Reply with quote

Hi.

I've refactored my existing two RCP projects to they take advantage of
the dependency-management feature of Maven: that is, this section is
present in the master pom:

<dependencyManagement>
<dependencies>
<dependency>
<groupId>nbm</groupId>
<artifactId>com-drew-metadata</artifactId>
<version>2.4.0-beta-1.4</version>
</dependency>
<dependency>
<groupId>nbm</groupId>
<artifactId>com-sun-media-imageio</artifactId>
<version>1.1.2</version>
</dependency>
<dependency>
<groupId>nbm</groupId>
<artifactId>javax-media-jai</artifactId>
<version>1.1.3.2</version>
</dependency>
<dependency>
<groupId>nbm</groupId>
<artifactId>org-apache-commons-io</artifactId>
<version>1.3.1.4</version>
</dependency>
...

and there are no more version references in the rest of the project -
with the exception of the nbm-application module (the one that creates
the custom platform for the project). While all the other modules
perfectly work, with the platform module I get problems. NetBeans
correctly detects the dependencyManagement section. I start with the
following in the nbm-application module:

<dependency>
<groupId>nbm</groupId>
<artifactId>com-drew-metadata</artifactId>
<version>2.4.0-beta-1.4</version>
<type>nbm</type>
</dependency>


I get the version element underlined in yellow, as NetBeans correctly
detects the dependencyManagement section; the lightbulb correctly
suggest me to drop the redundant version. I do for all dependencies getting:

<dependency>
<groupId>nbm</groupId>
<artifactId>com-drew-metadata</artifactId>
<type>nbm</type>
</dependency>

At this point I get this error from Maven:

[INFO] Scanning for projects...
[INFO]
------------------------------------------------------------------------
[ERROR] FATAL ERROR
[INFO]
------------------------------------------------------------------------
[INFO] Error building POM (may not be this project's POM).


Project ID: it.tidalwave.metadata:metadata-platform
POM Location: /Volumes/FastBuilds/blueMarine/Metadata/platform/pom.xml
Validation Messages:

[0] 'dependencies.dependency.version' is missing for
nbm:com-drew-metadata:nbm


Reason: Failed to validate POM for project
it.tidalwave.metadata:metadata-platform at
/Volumes/FastBuilds/blueMarine/Metadata/platform/pom.xml


[INFO]
------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.reactor.MavenExecutionException: Failed to validate POM
for project it.tidalwave.metadata:metadata-platform at
/Volumes/FastBuilds/blueMarine/Metadata/platform/pom.xml
at org.apache.maven.DefaultMaven.getProjects(DefaultMaven.java:432)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:300)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:137)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
at
org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:41)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.project.InvalidProjectModelException: Failed
to validate POM for project it.tidalwave.metadata:metadata-platform at
/Volumes/FastBuilds/blueMarine/Metadata/platform/pom.xml
at
org.apache.maven.project.DefaultMavenProjectBuilder.processProjectLogic(DefaultMavenProjectBuilder.java:1077)
at
org.apache.maven.project.DefaultMavenProjectBuilder.buildInternal(DefaultMavenProjectBuilder.java:880)
at
org.apache.maven.project.DefaultMavenProjectBuilder.buildFromSourceFileInternal(DefaultMavenProjectBuilder.java:508)
at
org.apache.maven.project.DefaultMavenProjectBuilder.build(DefaultMavenProjectBuilder.java:200)
at org.apache.maven.DefaultMaven.getProject(DefaultMaven.java:632)
at org.apache.maven.DefaultMaven.collectProjects(DefaultMaven.java:515)
at org.apache.maven.DefaultMaven.getProjects(DefaultMaven.java:419)
... 12 more

If I also drop the type element:

<dependency>
<groupId>nbm</groupId>
<artifactId>com-drew-metadata</artifactId>
</dependency>

Maven doesn't complain initially and starts working - but at the end I
get another error:

[Mistral:blueMarine/Metadata/platform] fritz% mvn clean install
[INFO] Scanning for projects...
[INFO]
------------------------------------------------------------------------
[INFO] Building Metadata (platform)
[INFO] task-segment: [clean, install]
[INFO]
------------------------------------------------------------------------
[INFO] [clean:clean {execution: default-clean}]
[INFO] Deleting directory
/Volumes/FastBuilds/blueMarine/Metadata/platform/target
[INFO] [nbm:cluster-app {execution: default-cluster-app}]
[INFO] Processing cluster 'platform10'
[INFO] Processing cluster 'libraries'
[INFO] Processing cluster 'openbluesky'
[INFO]
------------------------------------------------------------------------
[ERROR] FATAL ERROR
[INFO]
------------------------------------------------------------------------
[INFO] version was null for nbm:org-apache-commons-pool
[INFO]
------------------------------------------------------------------------
[INFO] Trace
java.lang.NullPointerException: version was null for
nbm:org-apache-commons-pool
at
org.apache.maven.artifact.DefaultArtifact.getBaseVersion(DefaultArtifact.java:390)
at
org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout.pathOf(DefaultRepositoryLayout.java:47)
at
org.apache.maven.artifact.repository.DefaultArtifactRepository.pathOf(DefaultArtifactRepository.java:110)
at
org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:141)
at
org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:90)
at
org.codehaus.mojo.nbm.AbstractNbmMojo.turnJarToNbmFile(AbstractNbmMojo.java:385)
at
org.codehaus.mojo.nbm.CreateClusterAppMojo.execute(CreateClusterAppMojo.java:151)
at
org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:483)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:678)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:540)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:519)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:371)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:332)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:181)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:356)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:137)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
at
org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:41)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)

Needless to say that the faulted dependency is correctly declared in the
dependencyManagement section:

<dependency>
<groupId>nbm</groupId>
<artifactId>org-apache-commons-pool</artifactId>
<version>1.4.3</version>
</dependency>

As Maven stops by error, I can't say whether the error would affect all
the dependency, or only org-apache-commons-pool. In any case, it is
treated as a number of other dependencies.

For the record, the groupId 'nbm' is from a separate project where I
pre-made all the required nbm wrapper libraries.

Any idea?



--
Fabrizio Giudici - Java Architect, Project Manager
Tidalwave s.a.s. - "We make Java work. Everywhere."
weblogs.java.net/blog/fabriziogiudici - www.tidalwave.it/blog
address-removed - mobile: +39 348.150.6941
Back to top
Moritz Uhlig
Posted via mailing list.





PostPosted: Sat Oct 03, 2009 7:04 pm    Post subject: Maven with dependency-management Reply with quote

Hi.

Just tried it with one of my projects - this is what seems to be
happening:

The section in your dependencyManagement could also be read like this:

<dependency>
<groupId>nbm</groupId>
<artifactId>com-drew-metadata</artifactId>
<version>2.4.0-beta-1.4</version>
<type>jar</type>
</dependency>

This is because when the type is omitted, Maven takes the default type
(jar). You simply have not defined a dependency-management for the nbm-
artifact.
I do not know if there is a clean way to do this - having to do this
for every artifact type is a bit tedious but seems to be the only
possibility.
It actually is a problem though if the Netbeans plugin marks the
version-tag as superfluous - as it actually is not in your case.


Regards,

Moritz


Am 03.10.2009 um 14:13 schrieb Fabrizio Giudici:

Quote:
Hi.

I've refactored my existing two RCP projects to they take advantage
of the dependency-management feature of Maven: that is, this section
is present in the master pom:

<dependencyManagement>
<dependencies>
<dependency>
<groupId>nbm</groupId>
<artifactId>com-drew-metadata</artifactId>
<version>2.4.0-beta-1.4</version>
</dependency>
<dependency>
<groupId>nbm</groupId>
<artifactId>com-sun-media-imageio</artifactId>
<version>1.1.2</version>
</dependency>
<dependency>
<groupId>nbm</groupId>
<artifactId>javax-media-jai</artifactId>
<version>1.1.3.2</version>
</dependency>
<dependency>
<groupId>nbm</groupId>
<artifactId>org-apache-commons-io</artifactId>
<version>1.3.1.4</version>
</dependency>
...

and there are no more version references in the rest of the project
- with the exception of the nbm-application module (the one that
creates the custom platform for the project). While all the other
modules perfectly work, with the platform module I get problems.
NetBeans correctly detects the dependencyManagement section. I start
with the following in the nbm-application module:

<dependency>
<groupId>nbm</groupId>
<artifactId>com-drew-metadata</artifactId>
<version>2.4.0-beta-1.4</version>
<type>nbm</type>
</dependency>


I get the version element underlined in yellow, as NetBeans
correctly detects the dependencyManagement section; the lightbulb
correctly suggest me to drop the redundant version. I do for all
dependencies getting:

<dependency>
<groupId>nbm</groupId>
<artifactId>com-drew-metadata</artifactId>
<type>nbm</type>
</dependency>

At this point I get this error from Maven:

[INFO] Scanning for projects...
[INFO]
------------------------------------------------------------------------
[ERROR] FATAL ERROR
[INFO]
------------------------------------------------------------------------
[INFO] Error building POM (may not be this project's POM).


Project ID: it.tidalwave.metadata:metadata-platform
POM Location: /Volumes/FastBuilds/blueMarine/Metadata/platform/pom.xml
Validation Messages:

[0] 'dependencies.dependency.version' is missing for nbm:com-drew-
metadata:nbm


Reason: Failed to validate POM for project
it.tidalwave.metadata:metadata-platform at /Volumes/FastBuilds/
blueMarine/Metadata/platform/pom.xml


[INFO]
------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.reactor.MavenExecutionException: Failed to validate
POM for project it.tidalwave.metadata:metadata-platform at /Volumes/
FastBuilds/blueMarine/Metadata/platform/pom.xml
at org.apache.maven.DefaultMaven.getProjects(DefaultMaven.java:432)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:300)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:137)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
at org.apache.maven.cli.compat.CompatibleMain.main
(CompatibleMain.java:41)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:
315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at org.codehaus.classworlds.Launcher.mainWithExitCode
(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.project.InvalidProjectModelException:
Failed to validate POM for project it.tidalwave.metadata:metadata-
platform at /Volumes/FastBuilds/blueMarine/Metadata/platform/pom.xml
at
org.apache.maven.project.DefaultMavenProjectBuilder.processProjectLogic
(DefaultMavenProjectBuilder.java:1077)
at
org.apache.maven.project.DefaultMavenProjectBuilder.buildInternal
(DefaultMavenProjectBuilder.java:880)
at
org.apache.maven.project.DefaultMavenProjectBuilder.buildFromSourceFileInternal
(DefaultMavenProjectBuilder.java:508)
at org.apache.maven.project.DefaultMavenProjectBuilder.build
(DefaultMavenProjectBuilder.java:200)
at org.apache.maven.DefaultMaven.getProject(DefaultMaven.java:632)
at org.apache.maven.DefaultMaven.collectProjects(DefaultMaven.java:
515)
at org.apache.maven.DefaultMaven.getProjects(DefaultMaven.java:419)
... 12 more

If I also drop the type element:

<dependency>
<groupId>nbm</groupId>
<artifactId>com-drew-metadata</artifactId>
</dependency>

Maven doesn't complain initially and starts working - but at the end
I get another error:

[Mistral:blueMarine/Metadata/platform] fritz% mvn clean install
[INFO] Scanning for projects...
[INFO]
------------------------------------------------------------------------
[INFO] Building Metadata (platform)
[INFO] task-segment: [clean, install]
[INFO]
------------------------------------------------------------------------
[INFO] [clean:clean {execution: default-clean}]
[INFO] Deleting directory /Volumes/FastBuilds/blueMarine/Metadata/
platform/target
[INFO] [nbm:cluster-app {execution: default-cluster-app}]
[INFO] Processing cluster 'platform10'
[INFO] Processing cluster 'libraries'
[INFO] Processing cluster 'openbluesky'
[INFO]
------------------------------------------------------------------------
[ERROR] FATAL ERROR
[INFO]
------------------------------------------------------------------------
[INFO] version was null for nbm:org-apache-commons-pool
[INFO]
------------------------------------------------------------------------
[INFO] Trace
java.lang.NullPointerException: version was null for nbm:org-apache-
commons-pool
at org.apache.maven.artifact.DefaultArtifact.getBaseVersion
(DefaultArtifact.java:390)
at
org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout.pathOf
(DefaultRepositoryLayout.java:47)
at
org.apache.maven.artifact.repository.DefaultArtifactRepository.pathOf
(DefaultArtifactRepository.java:110)
at
org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve
(DefaultArtifactResolver.java:141)
at
org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve
(DefaultArtifactResolver.java:90)
at org.codehaus.mojo.nbm.AbstractNbmMojo.turnJarToNbmFile
(AbstractNbmMojo.java:385)
at org.codehaus.mojo.nbm.CreateClusterAppMojo.execute
(CreateClusterAppMojo.java:151)
at org.apache.maven.plugin.DefaultPluginManager.executeMojo
(DefaultPluginManager.java:483)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals
(DefaultLifecycleExecutor.java:678)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle
(DefaultLifecycleExecutor.java:540)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal
(DefaultLifecycleExecutor.java:519)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures
(DefaultLifecycleExecutor.java:371)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments
(DefaultLifecycleExecutor.java:332)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute
(DefaultLifecycleExecutor.java:181)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:356)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:137)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
at org.apache.maven.cli.compat.CompatibleMain.main
(CompatibleMain.java:41)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:
315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at org.codehaus.classworlds.Launcher.mainWithExitCode
(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)

Needless to say that the faulted dependency is correctly declared in
the dependencyManagement section:

<dependency>
<groupId>nbm</groupId>
<artifactId>org-apache-commons-pool</artifactId>
<version>1.4.3</version>
</dependency>

As Maven stops by error, I can't say whether the error would affect
all the dependency, or only org-apache-commons-pool. In any case, it
is treated as a number of other dependencies.

For the record, the groupId 'nbm' is from a separate project where I
pre-made all the required nbm wrapper libraries.

Any idea?



--
Fabrizio Giudici - Java Architect, Project Manager
Tidalwave s.a.s. - "We make Java work. Everywhere."
weblogs.java.net/blog/fabriziogiudici - www.tidalwave.it/blog
address-removed - mobile: +39 348.150.6941
Back to top
Fabrizio Giudici
Posted via mailing list.





PostPosted: Sat Oct 03, 2009 7:23 pm    Post subject: Maven with dependency-management Reply with quote

Moritz Uhlig wrote:
Quote:
Hi.

Just tried it with one of my projects - this is what seems to be
happening:

The section in your dependencyManagement could also be read like this:

<dependency>
<groupId>nbm</groupId>
<artifactId>com-drew-metadata</artifactId>
<version>2.4.0-beta-1.4</version>
<type>jar</type>
</dependency>

This is because when the type is omitted, Maven takes the default type
(jar). You simply have not defined a dependency-management for the
nbm-artifact.
I do not know if there is a clean way to do this - having to do this
for every artifact type is a bit tedious but seems to be the only
possibility.
It actually is a problem though if the Netbeans plugin marks the
version-tag as superfluous - as it actually is not in your case.

Hmmm... I still have doubts about how dependencies should be declared.
Indeed I've just fixed the problem by dropping my local repository and
relaunching Maven. In my platform pom, I have stuff such as:

<dependency>
<groupId>it.tidalwave.openbluesky</groupId>
<artifactId>it-tidalwave-beans</artifactId>
</dependency>

That is, I don't have the <type>nbm</type> stuff, and the thing seems to
work. Which is the correct way?

--
Fabrizio Giudici - Java Architect, Project Manager
Tidalwave s.a.s. - "We make Java work. Everywhere."
weblogs.java.net/blog/fabriziogiudici - www.tidalwave.it/blog
address-removed - mobile: +39 348.150.6941
Back to top
Moritz Uhlig
Posted via mailing list.





PostPosted: Sat Oct 03, 2009 8:02 pm    Post subject: Maven with dependency-management Reply with quote

Which version of the nbm-maven-plugin are you using?

Milos changed the type name from nbm to nbm-file in 3.x and now you do
not need to refer to it directly anymore (it seems the plugin tries to
resolve any direct jar-dependency to a nbm-file dependency). In 2.x
you had to explicitly include the nbm-artifact (<type>nbm</type>) in
your POM if I remember correctly. Sorry - I was also confused by that.

So as long you are not using version 2.x you are doing the right thing
now.


Am 03.10.2009 um 21:23 schrieb Fabrizio Giudici:

Quote:
Hmmm... I still have doubts about how dependencies should be
declared. Indeed I've just fixed the problem by dropping my local
repository and relaunching Maven. In my platform pom, I have stuff
such as:

<dependency>
<groupId>it.tidalwave.openbluesky</groupId>
<artifactId>it-tidalwave-beans</artifactId>
</dependency>

That is, I don't have the <type>nbm</type> stuff, and the thing
seems to work. Which is the correct way?

--
Fabrizio Giudici - Java Architect, Project Manager
Tidalwave s.a.s. - "We make Java work. Everywhere."
weblogs.java.net/blog/fabriziogiudici - www.tidalwave.it/blog
address-removed - mobile: +39 348.150.6941
Back to top
Fabrizio Giudici
Posted via mailing list.





PostPosted: Sat Oct 03, 2009 8:50 pm    Post subject: Maven with dependency-management Reply with quote

Moritz Uhlig wrote:
Quote:
Which version of the nbm-maven-plugin are you using?

Milos changed the type name from nbm to nbm-file in 3.x and now you do
not need to refer to it directly anymore (it seems the plugin tries to
resolve any direct jar-dependency to a nbm-file dependency). In 2.x
you had to explicitly include the nbm-artifact (<type>nbm</type>) in
your POM if I remember correctly. Sorry - I was also confused by that.

So as long you are not using version 2.x you are doing the right thing
now.

3.1. Thanks for clarifying this thing, I was pretty confused.

--
Fabrizio Giudici - Java Architect, Project Manager
Tidalwave s.a.s. - "We make Java work. Everywhere."
weblogs.java.net/blog/fabriziogiudici - www.tidalwave.it/blog
address-removed - mobile: +39 348.150.6941
Back to top
Display posts from previous:   
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Platform Users All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo