简体   繁体   English

使用相对路径将一个 maven 项目包含到另一个 maven 项目中

[英]include one maven project into another maven project using the relative path

I have 3 maven applications.我有 3 个 maven 应用程序。

  • library-module: common code that can be reused library-module:可复用的通用代码
  • book-application: a web application that consumes the classes from library-module book-application:一个 web 应用程序,它使用library-module中的类
  • blog-application: a web application that consumes the classes from library-module too.博客应用程序:一个 web 应用程序,它也使用library-module中的类。

below are the poms of the modules:-以下是模块的poms:-

....
<!--library-application pom -->
<groupId>com.piyush</groupId>
<artifactId>library-module</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
....
....
<!--book-application pom-->
<groupId>com.piyush</groupId>
<artifactId>book-application</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
....
....
<!--blog-application pom-->
<groupId>com.piyush</groupId>
<artifactId>blog-application</artifactId>
<version>1.0</version>
<packaging>war</packaging>
....

Now I want to add library-application as dependency to book-application and blog-application as dependency like below:-现在我想将library-application作为依赖项添加到book-applicationblog-application作为依赖项,如下所示:-

....
<dependency>
    <groupId>com.piyush</groupId>
    <artifactId>library-module</artifactId>
    <version>1.0-SNAPSHOT</version>
</dependency>
....

now the catch over here is that I want the library-application jar to be generated before or during the compilation of book-application or blog-application .现在这里的问题是我希望在book-applicationblog-application编译之前或期间生成library-application jar 。 So that I don't have to add the jar as provided dependency.这样我就不必添加 jar 作为提供的依赖项。

If you want to build all three artifacts in one build, you can construct a multi-module project with three modules.如果您想在一个构建中构建所有三个工件,您可以构建一个包含三个模块的多模块项目。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM