Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
370 views
in Technique[技术] by (71.8m points)

java - How to include system dependencies in war built using maven

I've searched on internet for quite some time and I'm unable to figure out how to configure the maven-war plugin or something alike so that the system dependencies are included in the built-war (WEB-INF/lib folder)

I use the maven dependency plugin in case of a jar-build as :

<plugin>
    <artifactId>maven-dependency-plugin</artifactId>
    <executions>
        <execution>
            <phase>install</phase>
            <goals>
                <goal>copy-dependencies</goal>
            </goals>
            <configuration>
                <outputDirectory>${project.build.directory}/lib</outputDirectory>
            </configuration>
        </execution>
    </executions>
</plugin>

but I'm unable to understand what is to be done in case of a war build. I've tried using the maven-war plugin, but it's not including system-dependencies in the build.

[UPDATE]

I'm having depedencies of type :

<dependency>
    <groupId>LoginRadius</groupId>
    <artifactId>LoginRadius</artifactId>
    <scope>system</scope>
    <version>1.0</version>
    <systemPath>${basedir}libLoginRadius-1.0.jar</systemPath>
</dependency>

in my POM and these dependencies are not included in WEB-INF/lib when the war is build.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Let me try to summarise the options I tried :

<packagingIncludes>${java.home}/lib/jfxrt.jar</packagingIncludes>

This doesn't work! Also, only having the jar name, excludes everything else, so if you are willing to try then try

<packagingIncludes>${java.home}/lib/jfxrt.jar,**/*</packagingIncludes>

Jatin's answer seemed a bit complex and I tried going through the POM again & again to figure out where exactly were the system jars mentioned to be included in WEB-INF POM.

Anyways, I ended up using this solution, which wasn't working at first but after some time and some corrections worked :

I installed the jar in my local repository using the below command :

mvn install:install-file -Dfile="C:UsershpDocumentsNetBeansProjectsTwitterAndLoginRadiusMavenlibLoginRadius-1.0.jar" -DgroupId=LoginRadius -DartifactId=LoginRadius -Dversion=1.0 -Dpackaging=jar`

After running the above command, I changed the dependency in POM to

<dependency>
   <groupId>LoginRadius</groupId>
   <artifactId>LoginRadius</artifactId>
   <!--<scope>system</scope>-->
   <version>1.0</version>
   <!--<systemPath>${basedir}libLoginRadius-1.0.jar</systemPath>-->
</dependency>

NOTE - See I've commented the system scope & systemPath.

Building the war now, includes this LoginRadius-1.0.jar in WEB-INF/lib


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

56.9k users

...