Как скопировать внешнюю зависимость в Open Liberty во время сборки maven - PullRequest
2 голосов
/ 22 сентября 2019

Мне нужно скопировать 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 goal дважды.Похоже, что при выполнении liberty-maven-plugin папка ${project.build.directory}/liberty/wlp/usr/shared/resources/ удаляется, если в liberty/wlp/ отсутствует сервер свободы.

Maven LOG:

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

Может кто-нибудь помочь мне с этим?

1 Ответ

2 голосов
/ 23 сентября 2019

Вот пример из руководства Sache Cache от OpenLiberty.io, показывающий, как это можно сделать.Примером является получение hazelcast.jar, но его можно использовать для любого jar-файла, размещенного в 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>
...