Maven通过systemPath / system添加jar,但不添加到war或其他任何地方 [英] Maven add jars through systemPath/system but not added to war or anywhere else

查看:2076
本文介绍了Maven通过systemPath / system添加jar,但不添加到war或其他任何地方的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过systemPath从本地文件系统相对于我的项目目录结构添加一个jar文件,而不是在远程存储库上。我添加了依赖声明,但maven对它没有做任何其他事情。

I want to add a jar file through the systemPath from the local file-system relative to my project directory structure, not on a remote repository. I added the dependency declaration but maven doesn't do anything else with it.

在下面的声明中,我希望将jar文件复制到我的目标web-inf / lib目录,也作为战争文件的一部分震撼。目前,这种情况不会发生。如何将jar文件复制到我的war文件中?

In the declaration below, I want the jar file copied to my target web-inf/lib directory and also jarred as part of the war file. At present, that doesn't happen. How would I get the jar file copied to my war file?

这是调试maven模式的输出:

This is the output from debug maven mode:

DEBUG] cglib:cglib-nodep:jar:2.2:test (setting scope to: compile)^M
DEBUG] Retrieving parent-POM: org.objenesis:objenesis-parent:pom:1.2 for project: null:objenesis:ja
DEBUG]   org.objenesis:objenesis:jar:1.2:test (selected for test)^M
DEBUG]   org.javap.web:testRunWrapper:jar:1.0.0:system (selected for system)^M
DEBUG] Plugin dependencies for:
...


<dependency>
    <groupId>org.javap.web</groupId>
    <artifactId>testRunWrapper</artifactId>
    <version>1.0</version>
    <scope>system</scope>
    <systemPath>${basedir}/lib/testRunWrapper.jar</systemPath>
</dependency>
<plugin>
    <artifactId>maven-war-plugin</artifactId>
    <configuration>                 
        <webResources>
            <resource>
                <directory>WebContent</directory>
            </resource>
        </webResources>
    </configuration>
</plugin>


推荐答案

好的,我这样做了:注意目录结构底部。
使用下面的方法,来自相对项目路径的jar文件被视为与其他jar一样的一等公民。下面的列表更正了我原来的问题。使用下面的pom.xml列表,jar文件将复制到我的目标目录。

OK, I did this: Note the directory structure at the bottom. With the approach below, the jar file from the relative project path is treated as a first class citizen like the other jars. The listing below corrects my original problem. With the pom.xml listing below, the jar file is copied to my target directory.

<repositories>
    <repository>
        <id>JBoss</id>
        <name>JBoss Repository</name>
        <layout>default</layout>
        <url>http://repository.jboss.org/maven2</url>
    </repository>

    <repository>
       <id>my-local-repo</id>
       <url>file://${basedir}/lib/repo</url>
    </repository>
</repositories>

<dependency>
    <groupId>testRunWrapper</groupId>
    <artifactId>testRunWrapper</artifactId>
    <version>1.0.0</version>            
</dependency>







$ find repo
repo
repo/testRunWrapper
repo/testRunWrapper/testRunWrapper
repo/testRunWrapper/testRunWrapper/1.0.0
repo/testRunWrapper/testRunWrapper/1.0.0/testRunWrapper-1.0.0.jar

这篇关于Maven通过systemPath / system添加jar,但不添加到war或其他任何地方的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆