在 maven pom 文件中转换 属性 并将其复制到特定位置
To convert a property in maven pom file and copy it to a particular location
我想用下划线替换 project.version 属性 中的所有点,即我的 Maven pom.xml 中的 5.7 -->5_7 并仅复制被替换的文件夹将其打包为 jar 时的值,即 src/main/resources/5_7 到 db/oracle/5_7
Maven 中的东西并不是那样工作的。
如果您想通过 maven-resources-plugin
执行此操作,则这是不可能的。
作为一种解决方法,您可能最终想要使用 maven-antrun-plugin
并从那里进行 属性 更改和复制。
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>regex-property</id>
<goals>
<goal>regex-property</goal>
</goals>
<configuration>
<name>tag.version</name>
<value>${project.version}</value>
<regex>\.</regex>
<replacement>_</replacement>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.1</version>
<executions>
<execution>
<id>copy-resources</id>
<!-- here the phase you need -->
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/target/extraresources</outputDirectory>
<resources>
<resource>
<directory>src/main/resources/${migration}</directory>
<targetPath>db/oracle/${migration}</targetPath>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugins>
我想用下划线替换 project.version 属性 中的所有点,即我的 Maven pom.xml 中的 5.7 -->5_7 并仅复制被替换的文件夹将其打包为 jar 时的值,即 src/main/resources/5_7 到 db/oracle/5_7
Maven 中的东西并不是那样工作的。
如果您想通过 maven-resources-plugin
执行此操作,则这是不可能的。
作为一种解决方法,您可能最终想要使用 maven-antrun-plugin
并从那里进行 属性 更改和复制。
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>regex-property</id>
<goals>
<goal>regex-property</goal>
</goals>
<configuration>
<name>tag.version</name>
<value>${project.version}</value>
<regex>\.</regex>
<replacement>_</replacement>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.1</version>
<executions>
<execution>
<id>copy-resources</id>
<!-- here the phase you need -->
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/target/extraresources</outputDirectory>
<resources>
<resource>
<directory>src/main/resources/${migration}</directory>
<targetPath>db/oracle/${migration}</targetPath>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugins>