[英]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.