简体   繁体   English

如何将资源从一个Maven项目复制到另一个

[英]How to copy a resource from one maven project to another

i have a maven project consisting of a parent project with child projects. 我有一个Maven项目,其中包括一个父项目和一个子项目。 the children consist of many war projects and a single jar project (external). 孩子们包括许多战争项目和一个jar项目(外部)。 i want to copy a json file (keycloak.json) into the WEB-INF on all the war projects from a folder in the jar project. 我想从jar项目中的文件夹将json文件(keycloak.json)复制到所有war项目中的WEB-INF中。

so far i have it working by having a folder in every project containing all the keycloak.json. 到目前为止,我通过在每个项目中都有一个包含所有keycloak.json的文件夹来使其工作。 (a different keycloak.json is chosen depending on which maven profile is being used). (根据所使用的Maven配置文件选择不同的keycloak.json)。

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <version>${maven.war.plugin.version}</version>
    <configuration>
        <webResources>
            <resource>
                <directory>keycloak/${keycloak.dir}</directory>
                <targetPath>WEB-INF</targetPath>
                <filtering>true</filtering>
                <includes>
                    <include>**/keycloak.json</include>
                </includes>
            </resource>
        </webResources>
    </configuration>
</plugin>

i am trying to move to getting the keycloak.json copied from the jar file so i don't have to duplicate it 20 times in the other projects. 我试图移动到从jar文件复制keycloak.json,所以我不必在其他项目中重复20次。 so far i have tried the below which seems to copy the file to target, but it is not picked up by WTP in eclipse 到目前为止,我已经尝试了以下似乎将文件复制到目标的方法,但是在Eclipse中WTP并未将其提取

<plugin>
    <artifactId>maven-resources-plugin</artifactId>
    <executions>
        <execution>
            <id>copyKeycloak</id>
            <phase>generate-resources</phase>
            <goals>
                <goal>copy-resources</goal>
            </goals>
            <configuration>
                <outputDirectory>${project.build.directory}/WEB-INF</outputDirectory>
                <overwrite>true</overwrite>
                <resources>
                    <resource>
                        <directory>../external/src/main/resources/keycloak/${keycloak.dir}/</directory>
                        <includes>
                            <include>keycloak.json</include>
                        </includes>
                    </resource>
                </resources>
            </configuration>
        </execution>
    </executions>
</plugin>

in the end i found the solution which was much closer to my original. 最终,我找到了更接近于原始解决方案的解决方案。 it depends on the relative project paths from the parent pom which is not a problem in my case. 它取决于父pom的相对项目路径,在我看来,这不是问题。 external is the name of my jar 外部是我罐子的名字

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <version>${maven.war.plugin.version}</version>
    <configuration>
        <webResources>
            <resource>
                <directory>../external/src/main/resources/keycloak/${keycloak.dir}</directory>
                <targetPath>WEB-INF</targetPath>
                <filtering>true</filtering>
                <includes>
                    <include>**/keycloak.json</include>
                </includes>
            </resource>
        </webResources>
    </configuration>
</plugin>

暂无
暂无

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

相关问题 如何将 JUnit 测试从一个 Maven 项目导入到另一个项目? - How to import JUnit tests from one Maven project into another? 如何将Maven依赖项(jar文件)从一个Java项目复制到另一个动态Web项目的WEB-INF / lib文件夹? - How do you copy Maven dependencies (jar files) from one Java project to another Dynamic web project's WEB-INF/lib folder? 如何将Django项目从一个文件夹位置复制到另一个文件夹? - How to copy a django project from one folder location to another? 将源从一个Maven项目复制到另一个 - Copying sources from one maven project to another 使用位于项目根目录的maven复制资源文件 - Copy a resource file with maven located at the root of the project 在Eclipse中,如何从一个具有依赖项的另一个项目中排除一个maven项目的测试文件夹? - In Eclipse, how do I exclude test folder of one maven project from another project that has as a dependency? 如何将一个独立项目添加到另一个maven项目中 - How to add one standalone project into another maven project 如何将我的Eclipse Maven Selenium Webdriver TestNG Java项目从一台PC转移到另一台PC? - How to transfer my Eclipse Maven Selenium Webdriver TestNG Java project from one PC to another? 将Maven3项目从一个Eclipse实例导出到另一个 - Export Maven3 project from one eclipse instance to another 如何从一个 Maven 项目到另一个 Maven 项目获取文件夹、资源和 pom 文件? - How to get folders, resources and pom file from a maven project to another maven project?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM