How to configure maven for two separate projects that depend on the same jar

If this answers somewhere else, kindly hit me and call me in the right direction.

I am new to Maven and trying to wrap my head around how to use it with my projects. I have two top-level projects: one is a Swing application, the other is a set of web services. Both of them depend on the same internal jar. What are some good ways to create priests for this?

If the flask was used only by one of the projects, then it looks like I moved it inside and make it a module. But I don't need two (or later) copies of this jar source code.

In my opinion, I can do this to have a master litter for a Swing application that has a Swing application and a jar library as modules. Then create the same way to create a web application. Would that make sense? Are there any better ways?

The directory structure is currently very simple:

Development/  
----SwingApp/  
----WebServices/  
----CoreLibrary/  

Too much information and side questions:

" " ( "" ), 100% - ant Netbeans. Continuous Integration, TeamCity, . WebServices. , ant (build-impl.xml) , CI. - , , maven.

, , - , -, . Netbeans "CoreLibrary". , "CoreLibrary", , CoreLibrary . Maven? . , Netbeans (6.7) maven builds, , () Netbeans.

+3
5

pom, :

<project>
    <groupId>yourGroup</groupId>
    <artifactId>project</artifactId>
    <packaging>pom</packaging>
    <modules>
        <module>coreLibrary</module>
        <module>swingApp</module>
        <module>webServices</module>
    </modules>
</project>

, , , .

coreLibrary, swingApp webServices pom , .

<project>
    <parent>
        <groupId>yourGroup</groupId>
        <artifactId>project</artifactId>
        <version>yourVersion</version>
    </parent>
    <artifactId>webServices</artifactId>
    <packaging>war</packaging>
    <version>yourVersion</version>
    <dependencies>
        <dependency>
            <groupId>yourGroup</groupId>
            <artifactId>coreLibrary</artifactId>
            <version>yourVersion</version>
        </dependency>
    </dependencies>
</project>

, 3 , , -also-make web- ( coreLibrary)

mvn -am --projects webServices clean install 
+6

.jars. JAR- .pom . Maven .jars . .pom .jar maven ( -, .)

+3

, , , . :

  • ? ? ?
  • - SwingApp WebServices? SwingApp, WebServices? SwingApp, WebServices? SwingApp WebServices CoreLibrary?
  • 3 ?
  • CoreLibrary ?

, ( , ) , 3 . , . , :

my-app/           // this is the parent module, it aggregates the child modules  
|-- pom.xml       
|-- core-library  
|   `-- pom.xml   
|-- swing-app     // this module has a dependency on core-library  
|   `-- pom.xml   
`-- web-services  // this module has a dependency on core-library  
    `-- pom.xml   

, , :

  • . pom <modules>, 3 . , , Maven , Maven .
  • <parent>. pom
  • swing-app web- <dependency> , pom. maven .

swing-app - Maven ( ), , , . , -, JAR ( maven, " ", ).

. NetBeans , , ( ):

my-app/           
|-- parent
|   `-- pom.xml       
|-- core-library  
|   `-- pom.xml   
|-- swing-app     
|   `-- pom.xml   
`-- web-services  
    `-- pom.xml   

Multi Module Project Eclipse , Eclipse. 6. Sonatype Maven "" .

+3

jar . , maven , .

0

: Swing, - -. .

Maven? , JAR JAR, <dependency> POM.

Nexus - , Maven , , , "" , JAR .. Nexus - Sonatype, , , ..

0

Source: https://habr.com/ru/post/1721124/


All Articles