【问题标题】:copy jars used by plugin to single folder using Maven使用 Maven 将插件使用的 jar 复制到单个文件夹
【发布时间】:2014-06-21 10:21:48
【问题描述】:

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

<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>    

【问题讨论】:

  • 为什么要复制它们?你的目标是什么?

标签: maven


【解决方案1】:

mvn dependency: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。

【讨论】:

    【解决方案2】:

    如果你想使用依赖插件,你可以将依赖添加到 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 上运行依赖项:树(配置插件的位置)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-07-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多