[英]Why does the maven eclipse plugin break the maven jetty plugin?
I would like to have the maven eclipse plugin regenerate my .classpath whenever a build is run, and I did so by using the following configuration: 每当运行构建时,我都希望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>
For some reason, this causes the maven jetty plugin to fail with ClassNotFoundException errors (it complains about all sorts of Spring classes not being there). 由于某种原因,这会导致Maven Jetty插件因ClassNotFoundException错误而失败(它抱怨各种Spring类都不在那里)。 Of course, it worked without a hit when I didn't have the maven eclipse plugin installed.
当然,当我没有安装maven eclipse插件时,它没有受到任何影响。 Here's an example of what I'm talking about:
这是我正在谈论的示例:
$ 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)
Of course, if I delete that eclipse plugin section, I can run jetty as expected: 当然,如果删除该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.
Some things I know: 我知道一些事情:
Any advice? 有什么建议吗? This is a strange problem.
这是一个奇怪的问题。
Thanks, LES 谢谢,LES
I suspect the Maven Eclipse Plugin to
mess
do some classpath woodo that affects the jetty plugin later. 我怀疑Maven Eclipse插件会
搞乱
某些类路径,从而影响以后的码头插件。
But to be honest, this is not a very common way to use the Eclipse plugin, at least not to my knowledge. 但是,老实说,这并不是使用Eclipse插件的一种非常普遍的方式,至少就我所知。 Most people don't include it in their build, they just run it when the POM has changed and this generally doesn't happen every build.
大多数人没有在构建中包含它,而是在POM更改后才运行它,而且通常不会在每个构建中都发生。 Moreover, touching the
.classpath
confuses Eclipse if I remember well and forces a clean rebuild of the project which is pretty annoying. 此外,如果我还记得的话,触摸
.classpath
会使Eclipse感到困惑,并强制对项目进行干净的重新构建,这很烦人。
So at the end, and I'm sorry for that, this seems to introduce more annoyances than benefits. 所以最后,对此我感到抱歉,这似乎带来了更多的烦恼而不是好处。 You can try to open a Jira issue though.
您可以尝试打开一个Jira问题 。
You really don't want to run the maven-eclipse-plugin on every build when there's a .classpath present. 当存在.classpath时,您真的不想在每个构建上都运行maven-eclipse-plugin。 I can't tell you exactly what it does to the classpaths, but this is not how it's intended to be used.
我无法确切地告诉您它对类路径的作用,但这不是它打算如何使用的。 The assumption is that when you run it you only run eclipse:eclipse (or some other goal).
假设您在运行它时只运行eclipse:eclipse(或其他一些目标)。
Why do you want to keep re-running it? 为什么要继续运行它?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.