環境: Ubuntu 64 ビット、maven 3.0.4。
編集:方法を見つけました。以下の回答を参照してください。しかし、サルのパッチは、私が思いついたものと比較して、優れた設計の典型です...
このプラグインを使用して、JDK で使用するインターフェイスの実装を見つけますServiceLoader
。
私は Maven のスペシャリストではありません。解決方法がわからない問題に直面しています...プラグインの実行中 (以下の出力を参照)、生成されたファイルが生成された jar に表示されません :(でなんとtarget/classes
!_
私はかなり試してみましたが、何度もpomを壊してしまいました.この問題を解決する方法については完全に途方に暮れています. 以下の pom.xml のビルド セクションを変更して機能させるにはどうすればよいですか?
<!-- In case it matters: <packaging>bundle</packaging> -->
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9</version>
<configuration>
<links>
<link>http://docs.oracle.com/javase/6/docs/api</link>
<link>http://docs.guava-libraries.googlecode.com/git/javadoc</link>
<link>http://fge.github.io/msg-simple</link>
<link>http://jsr-305.googlecode.com/svn/trunk/javadoc</link>
<link>http://fge.github.com/btf</link>
</links>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<version>2.3.7</version>
</plugin>
<plugin>
<groupId>eu.somatik.serviceloader-maven-plugin</groupId>
<artifactId>serviceloader-maven-plugin</artifactId>
<version>1.0.2</version>
<configuration>
<services>
<param>com.github.fge.msgsimple.serviceloader.MessageBundleProvider</param>
</services>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
出力 (無関係な部分を取り除いたもの):
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building uri-template 0.5-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-enforcer-plugin:1.0:enforce (enforce-maven) @ uri-template ---
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ uri-template ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 2 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.0:compile (default-compile) @ uri-template ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 31 source files to /home/fge/src/perso/uri-template/target/classes
[INFO]
[INFO] --- serviceloader-maven-plugin:1.0.2:generate (default) @ uri-template ---
[INFO] Scanning generated classes for implementations...
[INFO] Generating service file /home/fge/src/perso/uri-template/target/classes/META-INF/services/com.github.fge.msgsimple.serviceloader.MessageBundleProvider
[INFO] + com.github.fge.uritemplate.URITemplateMessageBundle
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ uri-template ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 9 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.0:testCompile (default-testCompile) @ uri-template ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 20 source files to /home/fge/src/perso/uri-template/target/test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ uri-template ---
[INFO] Surefire report directory: /home/fge/src/perso/uri-template/target/surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running TestSuite
Configuring TestNG with: org.apache.maven.surefire.testng.conf.TestNG652Configurator@31c480e8
Tests run: 513, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.402 sec
Results :
Tests run: 513, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] --- maven-bundle-plugin:2.3.7:bundle (default-bundle) @ uri-template ---
[INFO]
[INFO] --- maven-javadoc-plugin:2.9:jar (default) @ uri-template ---
[INFO]
# Stripped javadoc build messages
[INFO] Building jar: /home/fge/src/perso/uri-template/target/uri-template-0.5-SNAPSHOT-javadoc.jar
[INFO]
[INFO] >>> maven-source-plugin:2.2.1:jar (default) @ uri-template >>>
[INFO]
[INFO] --- maven-enforcer-plugin:1.0:enforce (enforce-maven) @ uri-template ---
[INFO]
[INFO] <<< maven-source-plugin:2.2.1:jar (default) @ uri-template <<<
[INFO]
[INFO] --- maven-source-plugin:2.2.1:jar (default) @ uri-template ---
[INFO] Building jar: /home/fge/src/perso/uri-template/target/uri-template-0.5-SNAPSHOT-sources.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------