1

I have a Maven project that is packaged as a war, and I would like to use the Java classes from that package as a library dependency from a different project.

I tried just adding that dependency, but of course it is looking for a jar. I also tried adding the maven-war-plugin, but that didn't seem to help:

                <plugin>
                    <artifactId>maven-war-plugin</artifactId>
                    <version>2.1.1</version>
                    <configuration>
                        <attachClasses>true</attachClasses>
                        <classesClassifier>classes</classesClassifier>
                    </configuration>
                </plugin>
Victor Grazi
  • 15,563
  • 14
  • 61
  • 94
  • 4
    Create a jar project to create that library, and make it a dependency of your war project, and of your current project. – JB Nizet Jun 20 '16 at 17:14

1 Answers1

1

You can achieve that by adding modules in your root pom

 <modules>
        <module>module-one</module>
        <module>module-two</module>
         ...
 </modules>


and in your child modules you should add that it has a parent

<parent>
    <groupId>com.test.testy</groupId>
    <artifactId>nameOfArtifact</artifactId>
    <version>1.0</version>
</parent>

<artifactId>module-one</artifactId>
Hamedz
  • 726
  • 15
  • 27