使用Maven将插件使用的jar复制到单个文件夹

时间:2014-05-05 07:23:32

标签: maven

在我的POM.xml其他插件配置中,我不需要配置任何依赖项来运行插件。我想将插件(soapui-maven-plugin)使用的依赖jar从存储库下载到一个文件夹中。我尝试了命令“mvn dependency:copy-dependencies”,但没有复制jar。有没有办法做到这一点?

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>service.report</groupId>
<artifactId>service-report</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>Maven 2 SoapUI Sample</name>  
<build>
    <plugins>
        <plugin>           
        <groupId>com.smartbear.soapui</groupId>
        <artifactId>soapui-maven-plugin</artifactId>
        <version>5.0.0</version>            
                <executions>
                    <execution>
                        <phase>test</phase>
                        <goals>
                            <goal>loadtest</goal>
                        </goals>
                        <configuration>                             
                            <projectFile>${basedir}/src/main/resources/xxxxx-soapui-project.xml</projectFile>
                            <testSuite>xxxx</testSuite>
                            <testCase>sssss</testCase>
                            <loadTest>LoadTest 1</loadTest>
                            <outputFolder>${basedir}/target/surefire</outputFolder>
                            <junitReport>true</junitReport>
                            <exportAll>true</exportAll>
                            <printReport>true</printReport>
                            <testFailIgnore>false</testFailIgnore>
                            <!-- <projectProperties>
                                <value>message=Hello World!</value>
                            </projectProperties> -->
                        </configuration>
                    </execution>
                </executions>
            </plugin>
    </plugins>
</build>    

2 个答案:

答案 0 :(得分:1)

mvn依赖:copy-dependencies仅适用于当前的maven模块。它不适用于插件。如果要下载所有soapui-maven-plugin依赖项,则需要从soapui-maven-plugin项目执行命令。您可以按照以下步骤操作。我假设您熟悉GIT CLI。如果没有,您需要从https://github.com/SmartBear/soapui

手动下载
git clone https://github.com/SmartBear/soapui
cd soapui/soapui-maven-plugin
mvn dependency:copy-dependencies

您可以在soapui / soapui-maven-plugin / target / dependency(总共82个文件)中获取依赖项列表

[ERROR] Failed to execute goal on project soapui-maven-plugin: Could not resolve dependencies for project com.smartbear.soapui:soapui-maven-plugin:maven-plugin:5.0.0: Could not find artifact javafx:jfxrt:jar:2.2 at specified path (your jdk path)

如果您收到上述错误,则表示您的maven jdk是版本jdk.1.7(u6或更早版本),未与javafx一起安装。在http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html下载javafx附带的新jdk。记得把你的maven jdk改成这个更新的jdk。

答案 1 :(得分:0)

如果你想使用dependency-plugin,你可以将依赖项添加到pom ...并使用depepndency-plugin下载......

它适合我...

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.ab.forge.utility.copydependenciespom</groupId>
<artifactId>copydependenciespom</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>

<!-- BINARIES -->
<dependencies>
    <!--CUSTOMER RETURN -->
    <dependency>
        <groupId>com.ab...</groupId>
        <artifactId>customerret.....</artifactId>
        <version>1.0-SNAPSHOT</version>
        <scope>compile</scope>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
                <execution>
                    <phase>install</phase>
                    <goals>
                        <goal>copy-dependencies</goal>
                    </goals>
                    <configuration>
                        <overWriteIfNewer>true</overWriteIfNewer>
                        <overWriteReleases>true</overWriteReleases>
                        <overWriteSnapshots>true</overWriteSnapshots>

                        <excludeGroupIds>com.ab.ah.scad.acl</excludeGroupIds>
                        <excludeTypes>pom</excludeTypes>
                        <includeGroupIds>com.ab.oneleo</includeGroupIds>
                        <outputDirectory>${outputDirectory}</outputDirectory>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

在我运行安装后传递-DoutputDirectory参数....

试试这个......

要查看所有插件依赖项,您可以在pom上运行依赖项:树(配置中的插件)