ビルドが実行されるたびに、maven eclipse プラグインに .classpath を再生成させたいのですが、次の構成を使用して実行しました。
<!--
Generate a new .classpath each time the build is run, but don't try
to download sources or javadocs
-->
<profile>
<id>elipse-update</id>
<activation>
<file>
<exists>.classpath</exists>
</file>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-eclipse-plugin</artifactId>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>eclipse</goal>
</goals>
<configuration>
<downloadSources>false</downloadSources>
<downloadJavadocs>false</downloadJavadocs>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
何らかの理由で、これにより maven jetty プラグインが ClassNotFoundException エラーで失敗します (あらゆる種類の Spring クラスが存在しないというエラーが表示されます)。もちろん、maven eclipse プラグインがインストールされていない場合でも問題なく動作しました。これが私が話していることの例です:
$ mvn jetty:run
[INFO] Scanning for projects...
...
[INFO] Starting jetty 6.1.22 ...
2010-02-11 20:53:08.984:INFO::jetty-6.1.22
2010-02-11 20:53:09.109:WARN::Could not instantiate listener org.springframework.web.context.ContextLoaderListener
java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at org.codehaus.classworlds.RealmClassLoader.loadClassDirect(RealmClassLoader.java:195)
at org.codehaus.classworlds.DefaultClassRealm.loadClass(DefaultClassRealm.java:255)
at org.codehaus.classworlds.DefaultClassRealm.loadClass(DefaultClassRealm.java:274)
at org.codehaus.classworlds.RealmClassLoader.loadClass(RealmClassLoader.java:214)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
もちろん、その eclipse プラグイン セクションを削除すれば、予期したとおりに jetty を実行できます。
$ mvn jetty:run
[INFO] Scanning for projects...
...
Feb 11, 2010 8:55:28 PM org.springframework.web.context.ContextLoader initWebApplicationContext
INFO: Root WebApplicationContext: initialization completed in 1672 ms
2010-02-11 20:55:28.687:INFO::Started SelectChannelConnector@0.0.0.0:8080
[INFO] Started Jetty Server
[INFO] Starting scanner at interval of 5 seconds.
私が知っているいくつかのこと:
- はい、.classpath が存在する場合にのみ、このプロファイルを有効にします。これは直感に反しているように見えますが、私には理由があります。.classpath が存在しない場合にアクティブになる別のプロファイルがあり、ソース コードをダウンロードするオプションと javadocs を true に設定して Eclipse プラグインを実行します。ビルドごとにこれを発生させたくないので、クラスパスが既に存在する場合のために別のプラグイン構成を作成しました。
- はい、プラグイン構成全体を再度指定する代わりに、変更したいオプションの値を保持するプロパティを作成するだけで済みます。その場合、クラスパスの存在に応じて eclipse.downloadSources プロパティを true または false に設定し、通常のビルド セクションに単一のプラグイン定義を設定します。
何かアドバイス?これは奇妙な問題です。
ありがとう、レス