Maven 2 assembly with dependencies: jar under scope “system” not included

I’m not surprised that system scope dependencies are not added (after all, dependencies with a system scope must be explicitly provided by definition). Actually, if you really don’t want to put that dependency in your local repository (for example because you want to distribute it as part of your project), this is what I would do:

  • I would put the dependency in a “file system repository” local to the project.
  • I would declare that repository in my pom.xml like this:

    <repositories>
      <repository>
        <id>my</id>
        <url>file://${basedir}/my-repo</url>
      </repository>
    </repositories>
    
  • I would just declare the artifact without the system scope, this is just a source of troubles:

    <dependency>
      <groupId>sourceforge.jchart2d</groupId>
      <artifactId>jchart2d</artifactId>
      <version>3.1.0</version>
    </dependency>
    

I’m not 100% sure this will suit your needs but I think it’s a better solution than using the system scope.

Update: I should have mentioned that in my original answer and I’m fixing it now. To install a third party library in the file-based repository, use install:install-file with the localRepositoryPath parameter:

mvn install:install-file -Dfile=<path-to-file> \
                         -DgroupId=<myGroup> \
                         -DartifactId=<myArtifactId> \
                         -Dversion=<myVersion> \
                         -Dpackaging=<myPackaging> \
                         -DlocalRepositoryPath=<path-to-my-repo>

You can paste this as is in a *nix shell. On windows, remove the “\” and put everything on a single line.

Leave a Comment