更新 - 2021 年 7 月:
虽然使用依赖插件的公认答案是当时最好的解决方案,但@ltlBeBoy 的答案利用了自从添加到 liberty-maven-plugin 以来的“copyDependencies”支持。使用“copyDependencies”通常是一个更好的解决方案,因为它被集成到“开发模式”循环中并且不那么冗长(以支持比依赖插件更少的选项为代价)。
原始问题
我需要复制derby.jar
到 Open Liberty 共享目录
${project.build.directory}/liberty/wlp/usr/shared/resources/
中。我在 pom.xml 文件中有以下设置:
<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>
以及配置开放自由的部分
<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
在.${project.build.directory}/liberty/wlp/usr/shared/resources/
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.
有人可以帮我吗?