実行可能パッケージ(JAR形式)を作成する必要があるMavenアーティファクトを作成しようとしています。このアーティファクトは、アーティファクトorg.apache.uima.uimafit-core
2.1.0:アセンブリ時にMaven依存関係に含まれるリソースに「追加」する方法
classpath*:desc/type/metadata.xml
したがって、プロジェクトの構造はこのような何かを見て:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.stackoverflow.examples</groupId>
<artifactId>amend-included-resource</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>${project.artifactId}</name>
<properties>
<java.version>1.8</java.version>
<mainClass>com.stackoverflow.examples.AnalysisEngineTest</mainClass>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<!-- Adapted from <http://stackoverflow.com/a/574650/1391325> -->
<artifactId>maven-assembly-plugin</artifactId>
<version>2.6</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>${mainClass}</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id> <!-- this is used for inheritance merges -->
<phase>package</phase> <!-- bind to the packaging phase -->
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.stackoverflow.examples</groupId>
<artifactId>uimafit-stuff</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
依存uimafit-stuff
がa uimaFIT types.txt
type description filemain/resources/META-INF/types.txt
の下で定義されて
uimafit-stuff
├── desc
│ ├── type
│ │ ├── metadata.xml
├── META-INF
│ ├── org.apache.uima.fit
│ │ ├── types.txt < "classpath*:desc/type/metadata.xml"
はまた、私はamend-included-resource/src/main/resources/META-INF/types.txt
の下で自分のtypes.txt
ファイルがあります:私のパッケージが動作するためには
classpath*:desc/types/MyOwnSpecialType.xml
を、私は(これらのファイルのそれぞれで表さ型記述子の和集合を必要としますすなわち、私はタイプ記述子パスをインクルードファイルに追加する必要があります(その逆もあります)。私はmvn package
実行すると、依存関係のないアーティファクトファイルが含まれているだけで、「私の」types.txt
:
amend-included-resource-0.0.1-SNAPSHOT.jar
├── desc
│ ├── types
│ │ ├── MyOwnSpecialType.xml
├── META-INF
│ ├── org.apache.uima.fit
│ │ ├── types.txt < "classpath*:desc/types/MyOwnSpecialType.xml"
しかし、アセンブリjar-with-dependencies
はuimafit-stuff
ではなく、私自身のプロジェクトから1からtypes.txt
のファイルが含まれている記述子を使用中に作成されたJAR:
amend-included-resource-0.0.1-SNAPSHOT-jar-with-dependencies.jar
├── desc
│ ├── type
│ │ ├── metadata.xml
│ ├── types
│ │ ├── MyOwnSpecialType.xml
├── META-INF
│ ├── org.apache.uima.fit
│ │ ├── types.txt < "classpath*:desc/type/metadata.xml"
どのように私は、私はランタイムエラーなしで私の組み立てjarファイルを実行できるように、リソースtypes.txt
の両方のバージョンが何らかの形で「統一」であることを確認することができますか?
はhttps://maven.apache.org/plugins/maven-shade-plugin([mavenのシェード-プラグイン]深く見てみます/)は、この種のファイルに関してより柔軟性があります... – khmarbaise