问题描述
我需要将derby.jar
复制到Open Liberty共享目录${project.build.directory}/liberty/wlp/usr/shared/resources/
中.我在pom.xml文件中进行了以下设置:
I need to copy derby.jar
into Open Liberty shared directory ${project.build.directory}/liberty/wlp/usr/shared/resources/
. I have the following setup in the pom.xml file:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.10</version>
<executions>
<execution>
<id>copy-derby-dependency</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<includeArtifactIds>derby</includeArtifactIds>
<outputDirectory>${project.build.directory}/liberty/wlp/usr/shared/resources/</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
以及用于配置开放自由的部分
and the part for configuring open liberty
<plugin>
<groupId>net.wasdev.wlp.maven.plugins</groupId>
<artifactId>liberty-maven-plugin</artifactId>
<version>${openliberty.maven.version}</version>
<executions>
<execution>
<id>package-server</id>
<phase>package</phase>
<goals>
<goal>create-server</goal>
<goal>install-apps</goal>
<goal>package-server</goal>
</goals>
<configuration>
<outputDirectory>target/wlp-package</outputDirectory>
</configuration>
</execution>
</executions>
<configuration>
<assemblyArtifact>
<groupId>io.openliberty</groupId>
<artifactId>openliberty-runtime</artifactId>
<version>${openliberty.version}</version>
<type>zip</type>
</assemblyArtifact>
<configFile>src/main/liberty/config/server.xml</configFile>
<appArchive>${project.build.directory}/${final.name}.war</appArchive>
<packageFile>${project.build.directory}/${final.name}.jar</packageFile>
<include>runnable</include>
<serverName>${final.name}</serverName>
<installAppPackages>project</installAppPackages>
<configDirectory>${project.basedir}/src/main/liberty/server</configDirectory>
<bootstrapProperties>
<project.name>${final.name}</project.name>
<jwt.issuer>https://server.example.com</jwt.issuer>
</bootstrapProperties>
</configuration>
</plugin>
使用此设置,我必须执行两次mvn package
目标.看起来在执行liberty-maven-plugin
时,如果liberty/wlp/
下没有自由服务器,则会删除${project.build.directory}/liberty/wlp/usr/shared/resources/
文件夹.
With this setup I have to execute mvn package
goal twice. It looks like that when liberty-maven-plugin
is executed the ${project.build.directory}/liberty/wlp/usr/shared/resources/
folder is removed if there is no liberty server under liberty/wlp/
.
Maven日志:
[INFO] --- maven-dependency-plugin:2.10:copy-dependencies (copy-derby-dependency) @ account ---
[INFO] Copying derby-10.15.1.3.jar to /Users/anton/github/account/target/liberty/wlp/usr/shared/resources/derby-10.15.1.3.jar
and after it
[INFO] --- liberty-maven-plugin:2.2:create-server (package-server) @ account ---
[INFO] CWWKM2110I: Uninstalling: /Users/anton/github/account/target/liberty/wlp.
有人可以帮我吗?
推荐答案
下面是OpenLiberty.io的会话缓存"指南中的一个示例,显示了如何完成此操作.该示例正在获取hazelcast.jar,但它可用于maven中托管的任何jar.
Here's an example from the Session Cache guide from OpenLiberty.io showing how this can be done. The example is getting a hazelcast.jar, but it could be used for any jar hosted in maven.
https://github.com/OpenLiberty/guide -sessions/blob/master/finish/pom.xml
<!-- package hazelcast.jar -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.1.1</version>
<executions>
<execution>
<id>copy</id>
<phase>package</phase>
<goals>
<goal>copy</goal>
</goals>
</execution>
</executions>
<configuration>
<artifactItems>
<artifactItem>
<groupId>com.hazelcast</groupId>
<artifactId>hazelcast</artifactId>
<version>${hazelcast.version}</version>
<type>jar</type>
<overWrite>false</overWrite>
<outputDirectory>${project.build.directory}/liberty/wlp/usr/shared/resources</outputDirectory>
<destFileName>hazelcast.jar</destFileName>
</artifactItem>
</artifactItems>
<outputDirectory>${project.build.directory}/liberty/wlp/usr/shared/resources</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>true</overWriteSnapshots>
</configuration>
</plugin>
这篇关于在Maven构建期间如何将外部依赖项复制到Open Liberty的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!