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\commons-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

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to