maven 解包依赖项中的文件

2022-07-20 13:40:06 浏览数 (1)

插件

maven-dependency-plugin:2.8

解包当前模块依赖的maven模块中的文件

使用goal:unpack-dependencies 在配置参数includeArtifactIds中指定要解包的模块制件ID

代码语言:javascript复制
<build>
	<plugins>
		<plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
                <execution>
                    <id>unpack-dependencies</id>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>unpack-dependencies</goal>
                    </goals>
                    <configuration>
                        <includeArtifactIds>my-maven-module</includeArtifactIds>
                        <outputDirectory>${project.build.directory}/classes</outputDirectory>
                    </configuration>
                </execution>
			</executions>
        </plugin>
    </plugins>
</build>

解包指定maven模块中的文件

使用goal:unpack 可以指定非当前模块所以来的maven模块

代码语言:javascript复制
<build>
	<plugins>
		<plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
                <execution>
                    <id>unpack</id>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>unpack</goal>
                    </goals>
                    <configuration>
                        <artifactItems>
                            <artifactItem>
                                <groupId>org.my-project</groupId>
                                <artifactId>my-maven-module</artifactId>
                                <outputDirectory>${project.build.directory}/classes</outputDirectory>
                                <includes>lib/mylib.so</includes>
                            </artifactItem>
                        </artifactItems>
                    </configuration>
                </execution>
			</executions>
        </plugin>
    </plugins>
</build>

0 人点赞