maven copy plugin


    1. Copy the specified file to the webroot directory when the maven-war-plugin plugin is packaged
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.4</version>
                <configuration>
                    <webResources>
                        <resource>
                            <directory>src/main/webapp/src/css</directory>
                        </resource>
                    </webResources>
                </configuration>
            </plugin>



2. The maven-resources-plugin plugin
    copies the specified files to any directory when packaging. The following code copies the files in the src/main/webapp/src/css directory to the target directory. When packaging, the contents of the target directory will be packaged to the webroot directory.
             <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>2.5</version>
                <executions>
                    <execution>
                        <id>copy-resources</id>
                        <phase>package</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <encoding>UTF-8</encoding>
                            <outputDirectory>${basedir}/target</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>src/main/webapp/src/css</directory>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>


3. Resource module
    When developing a maven project, the configuration file is generally placed in the src/main/resources directory. For this directory, maven's resources are configured separately.
                 <resources>
                    <resource>
                        <directory>src/main/resources/conf/dev</directory>
                        <filtering>true</filtering>
                        <includes>
                            <include>context.xml</include>
                        </includes>
                    </resource>
                    <resource>
                        <directory>src/main/resources/</directory>
                        <filtering>false</filtering>
                        <excludes>
                            <exclude>context.xml</exclude>
                        </excludes>
                    </resource>
                  </resources>

When filtering is true, only the filtered files will be placed under the classpath.

4. Maven built-in variables
  • ${basedir} project root directory
  • ${project.build.directory} build directory, default is target
  • ${project.build.outputDirectory} build process output directory, default is target/classes
  • ${project.build.finalName} Artifact name, default is ${project.artifactId}-${project.version}
  • ${project.packaging} packaging type, the default is jar
  • ${project.xxx} The content of any node of the current pom file


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326443753&siteId=291194637