Eric, Short answer, please don't do it. Plugins that add dependencies like that cause major grief to any ide integrations and also make it impossible to change versions of used dependencies, essentially making your plugin less useful.
regards, Eugene Lewis, Eric-2 wrote: > > Anyone? :-) > >> -----Ursprüngliche Nachricht----- >> Von: Lewis, Eric [mailto:[email protected]] >> Gesendet: Dienstag, 13. Januar 2009 14:15 >> An: Maven Users List >> Betreff: How to add a dependency dynamically during the build >> in a plugin? >> >> Hi >> >> I just started to write my first plugin which should add some JARs >> dynamically to the project's dependencies. >> Unfortunately, I found no documentation about how to add a >> dependency at >> runtime (Sonatype book, Maven site, blogs...). >> >> I have the project injected by Plexus and want to add some >> dependencies >> like this: >> Dependency dependency = new Dependency(); >> dependency.setGroupId(groupId); >> dependency.setArtifactId(artifactId); >> dependency.setVersion(version); >> dependency.setScope("system"); >> dependency.setSystemPath(jarFile.getAbsolutePath()); >> this.project.getDependencies().add(dependency); >> >> When using this.project.getDependencies() later on, I find those >> dependencies. >> >> However, I also added the Maven dependency plugin later in >> the build to >> have a list of dependencies: >> <plugin> >> <groupId>org.apache.maven.plugins</groupId> >> <artifactId>maven-dependency-plugin</artifactId> >> <executions> >> <execution> >> <phase>package</phase> >> <goals> >> <goal>list</goal> >> </goals> >> </execution> >> </executions> >> <configuration> >> <outputScope>true</outputScope> >> >> <outputAbsoluteArtifactFilename>true</outputAbsoluteArtifactFilename> >> </configuration> >> </plugin> >> >> But it only shows the existing dependencies from the POM: >> [INFO] [dependency:list {execution: default}] >> [INFO] >> [INFO] The following files have been resolved: >> [INFO] commons-lang:commons-lang:jar:2.4:compile:C:\Documents and >> Settings\xyz\.m2\repository\commons-lang\commons-lang\2.4\comm >> ons-lang-2 >> .4.jar >> >> So obviously, it doesn't work. >> >> I also tried >> this.project.getDependencyManagement().addDependency(dependency); >> >> which didn't change anything. >> >> Is there a reference about the internals of the dependency mechanism? >> >> Best regards, >> Eric > -- View this message in context: http://www.nabble.com/How-to-add-a-dependency-dynamically-during-the-build-in-a-plugin--tp21435580p21480117.html Sent from the Maven - Users mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
