聚合器pom调用Maven时,Maven无法读取子模块的资源

聚合器pom调用Maven时,Maven无法读取子模块的资源,maven,Maven,我有几个模块运行“mvn clean install”并且必须维护它们的顺序。为了让我的生活更轻松,不必更改TFS或任何东西,我考虑创建一个包含我所有子模块的,而他们对此聚合器一无所知。 我的项目结构: projectaggregator | +- submodule1 | +- submodule2 聚合器/pom.xml: <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2

我有几个模块运行“
mvn clean install
”并且必须维护它们的顺序。为了让我的生活更轻松,不必更改
TFS
或任何东西,我考虑创建一个包含我所有
子模块的
,而他们对此
聚合器一无所知。
我的项目结构:

projectaggregator
|
+- submodule1
|
+- submodule2
聚合器/pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.my.package</groupId>
    <artifactId>projectaggregator</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>pom</packaging>
    <name>Project Aggregator</name>

    <modules>
        <module>../submodule1</module>
        <!--<module>../submodule2</module>-->       
    </modules>
</project>
...
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.3.RELEASE</version>
    </parent>
    <dependencies>
        <dependency>
            <groupId>io.swagger</groupId>
            <artifactId>swagger-codegen-maven-plugin</artifactId>
            <version>2.3.1</version>
        </dependency>
    ...
子模块1/pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.my.package</groupId>
    <artifactId>projectaggregator</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>pom</packaging>
    <name>Project Aggregator</name>

    <modules>
        <module>../submodule1</module>
        <!--<module>../submodule2</module>-->       
    </modules>
</project>
...
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.3.RELEASE</version>
    </parent>
    <dependencies>
        <dependency>
            <groupId>io.swagger</groupId>
            <artifactId>swagger-codegen-maven-plugin</artifactId>
            <version>2.3.1</version>
        </dependency>
    ...
。。。
org.springframework.boot
spring启动程序父级
2.0.3.1发布
昂首阔步
swagger codegen maven插件
2.3.1
...
显然,
submodule1
无法找到资源,因为我们正在通过
聚合器运行
submodule1

是否有任何方法可以解决资源的
相对路径
,而无需修改
子模块1
pom文件?

我在使用swagger执行多模块构建时遇到了同样的问题。在查看资源路径时,swagger插件显然存在一个限制。 我们可以通过在我们的swagger插件配置中使用maven变量
${project.basedir}
来解决这个问题:

<plugin>
    <groupId>io.swagger</groupId>
    <artifactId>swagger-codegen-maven-plugin</artifactId>
    <version>2.2.1</version>
    <executions><execution>
        <goals><goal>generate</goal></goals>
        <phase>generate-sources</phase>
        <configuration>
            <inputSpec>${project.basedir}/src/main/resources/yaml/decision.yaml</inputSpec>
        </configuration>
    </execution></executions>
</plugin>


昂首阔步

搜索了很长时间才找到这个!谢谢@mailtobash。