Copying multiple resource directories to independent target directories with maven

前端 未结 9 1425
终归单人心
终归单人心 2020-12-05 04:03

The Maven resources plugin:

This goal requires that you configure the resources to be copied, and specify the outputDirectory.

C

相关标签:
9条回答
  • 2020-12-05 04:33

    If you want to copy more directories or files - a better option:

      <plugin>
        <artifactId>maven-resources-plugin</artifactId>
        <version>2.6</version>
        <executions>
          <execution>
            <id>copy-resources</id>
            <phase>validate</phase>
            <goals>
              <goal>copy-resources</goal>
            </goals>
            <configuration>
              <tasks>
                <copy todir="${basedir}/target/blah" overwrite="true">
                     <fileset dir="blah"/>
                </copy>
                <copy file="${basedir}/target/blah/somefile"
                      todir="../target_webapp_eclaims/WEB-INF" overwrite="true"/>
              </tasks>
            </configuration>
          </execution>
        </executions>
      </plugin>
    
    0 讨论(0)
  • 2020-12-05 04:34

    You can use ant-style patterns

    <plugin>
        <artifactId>maven-resources-plugin</artifactId>
        <version>2.7</version>
        <executions>
            <execution>
                <id>copy-resources</id>
                <phase>validate</phase>
                <goals>
                    <goal>copy-resources</goal>
                </goals>
                <configuration>
                    <outputDirectory>${project.build.directory}</outputDirectory>
                    <resources>
                        <resource>
                            <directory>${basedir}</directory>
                            <includes>
                                <include>blah/**</include>
                                <include>uggh/**</include>
                            </includes>
                        </resource>
                    </resources>
                </configuration>
            </execution>
        </executions>
    </plugin>
    
    0 讨论(0)
  • 2020-12-05 04:38
            <resources>
              <resource>
                <directory>src/main/resources</directory>
                <filtering>false</filtering>
                <targetPath>${basedir}/target</targetPath>
              </resource>
              <resource>
                <directory>src/main/resources</directory>
                <filtering>false</filtering>
                <targetPath>${basedir}/target/classes</targetPath>
              </resource>
           </resources>
    
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.6.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>3.0.2</version>
                <configuration>
                    <nonFilteredFileExtensions>
                        <nonFilteredFileExtension>jks</nonFilteredFileExtension>
                    </nonFilteredFileExtensions>
                    <executions>
                        <execution>
                            <id>copy-resources-1</id>
                            <phase>validate</phase>
                            <goals>
                                <goal>copy-resources</goal>
                            </goals>
                        </execution>
                    </executions>
                </configuration>
            </plugin>
       </plugins>
    

    0 讨论(0)
提交回复
热议问题