Question

I have two Maven (GWT) Projects and one should depend on the other. I just added the dependency like:

<dependency>
    <groupId>myGroup</groupId>
    <artifactId>MyArtifact</artifactId>
    <version>1.0-SNAPSHOT</version>
    <scope>compile</scope>
</dependency>

The classes are referenced correctly and I can use them in my other project. But if I want to trigger a maven build, it complains with: "Could not resolve dependencies for project: Could not find artifact myGroup:MyArtifact:jar:1.0-SNAPSHOT"

The project has no jar because it is an GWT Web application. It has a "war" file. I testet around with the argument and tried values like "pom" or "war". It then does not show that error, but unit tests do fail because classes from the other project can not be found.

Was it helpful?

Solution

You need to define in the other project which is a war packaging things like this:

  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-war-plugin</artifactId>
      <version>2.4</version>
      <configuration>
        <attachClasses>true</attachClasses>
      </configuration>
    </plugin>
    ...
  </plugins>

This will create an artifact with the classifier classes which can be referenced in other projects like this (

<dependency>
  <groupId>myGroup</groupId>
  <artifactId>myArtifact</artifactId>
  <version>myVersion</myVersion>
  <classifier>classes</classifier>
</dependency>

OTHER TIPS

First call maven install for MyArtifact project that will create a jar and will place it in your local maven repository.

Now you can use maven build for dependent project.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top