maven-remote-resources-plugin 不将资源复制到其他模块

问题描述 投票:0回答:0

我正在尝试使用

maven-remote-resources-plugin
将资源从一个模块(合同商店)复制到多模块 maven 项目中的其他模块(api-合同)。复制所需的资源在
src/main/resources
中。在构建 contract-store maven 项目时,我可以看到以下日志:

[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:3.2.0:clean (default-clean) @ contract-store ---
[INFO] Deleting /Users/shubhamrathi/Coding/ecommerce-system/contract-store/target
[INFO] 
[INFO] --- maven-remote-resources-plugin:1.7.0:bundle (default) @ contract-store ---
[INFO] Writing META-INF/maven/remote-resources.xml descriptor with 2 entries
[INFO] 
[INFO] --- maven-resources-plugin:3.2.0:resources (default-resources) @ contract-store ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] Copying 1 resource
[INFO] Copying 2 resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.10.1:compile (default-compile) @ contract-store ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /Users/shubhamrathi/Coding/ecommerce-system/contract-store/target/classes
[INFO] 
[INFO] --- maven-remote-resources-plugin:1.7.0:bundle (default) @ contract-store ---
[INFO] Writing META-INF/maven/remote-resources.xml descriptor with 2 entries
[INFO] 
[INFO] --- maven-resources-plugin:3.2.0:resources (default-resources) @ contract-store ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] Copying 1 resource
[INFO] Copying 2 resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.10.1:compile (default-compile) @ contract-store ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /Users/shubhamrathi/Coding/ecommerce-system/contract-store/target/classes
[INFO] 
[INFO] --- maven-resources-plugin:3.2.0:testResources (default-testResources) @ contract-store ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] skip non existing resourceDirectory /Users/shubhamrathi/Coding/ecommerce-system/contract-store/src/test/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.10.1:testCompile (default-testCompile) @ contract-store ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /Users/shubhamrathi/Coding/ecommerce-system/contract-store/target/test-classes
[INFO] 
[INFO] --- maven-surefire-plugin:2.22.2:test (default-test) @ contract-store ---

在构建 api-contracts maven 项目时,我可以看到以下日志:

Building api-contracts 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:3.2.0:clean (default-clean) @ api-contracts ---
[INFO] Deleting /Users/shubhamrathi/Coding/ecommerce-system/api-contracts/target
[INFO] 
[INFO] --- maven-remote-resources-plugin:1.7.0:process (default) @ api-contracts ---
[INFO] Preparing remote bundle com.ecommerce:contract-store:0.0.1-SNAPSHOT
[INFO] Copying 2 resources from 1 bundle.
[INFO] 
[INFO] --- maven-resources-plugin:3.2.0:resources (default-resources) @ api-contracts ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] Copying 0 resource
[INFO] Copying 0 resource
[INFO] Copying 0 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.10.1:compile (default-compile) @ api-contracts ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /Users/shubhamrathi/Coding/ecommerce-system/api-contracts/target/classes
[INFO] 
[INFO] --- maven-remote-resources-plugin:1.7.0:process (default) @ api-contracts ---
[INFO] Preparing remote bundle com.ecommerce:contract-store:0.0.1-SNAPSHOT
[INFO] Copying 2 resources from 1 bundle.
[INFO] 
[INFO] --- maven-resources-plugin:3.2.0:resources (default-resources) @ api-contracts ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] Copying 0 resource
[INFO] Copying 0 resource
[INFO] Copying 0 resource
[INFO] Copying 0 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.10.1:compile (default-compile) @ api-contracts ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /Users/shubhamrathi/Coding/ecommerce-system/api-contracts/target/classes
[INFO] 
[INFO] --- maven-resources-plugin:3.2.0:testResources (default-testResources) @ api-contracts ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] skip non existing resourceDirectory /Users/shubhamrathi/Coding/ecommerce-system/api-contracts/src/test/resources
[INFO] Copying 0 resource
[INFO] Copying 0 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.10.1:testCompile (default-testCompile) @ api-contracts ---
[INFO] No sources to compile

合同商店pom:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-remote-resources-plugin</artifactId>
            <version>1.7.0</version>
            <executions>
                <execution>
                    <goals>
                        <goal>bundle</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <includes>
                    <include>**/*.yml</include>
                </includes>
            </configuration>
        </plugin>
    </plugins>
</build>

api-合同 pom:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-remote-resources-plugin</artifactId>
    <version>1.7.0</version>
    <configuration>
        <resourceBundles>
            <resourceBundle>com.ecommerce:contract-store:${project.version}</resourceBundle>
        </resourceBundles>
    </configuration>
    <executions>
        <execution>
            <goals>
                <goal>process</goal>
            </goals>
        </execution>
    </executions>
</plugin>

生成的remote-resources.xml

<?xml version="1.0" encoding="UTF-8"?>
<remoteResourcesBundle xsi:schemaLocation="http://maven.apache.org/remote-resources/1.1.0 https://maven.apache.org/xsd/remote-resources-1.1.0.xsd"
    xmlns="http://maven.apache.org/remote-resources/1.1.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <remoteResources>
    <remoteResource>customer.yml</remoteResource>
    <remoteResource>item.yml</remoteResource>
  </remoteResources>
  <sourceEncoding>UTF-8</sourceEncoding>
</remoteResourcesBundle>

我可以在 api-contracts 的目标目录中看到名为

maven-shared-archive-resources
的新文件夹,但它不包含这 2 个资源文件。 有人可以帮我吗?

java maven maven-plugin
© www.soinside.com 2019 - 2024. All rights reserved.