使用 maven jetty:run 时 - 是否可以禁用编译步骤?

发布于 2024-11-04 22:43:27 字数 1193 浏览 1 评论 0原文

我正在使用 Eclipse 和 Maven,并使用 Maven jetty 插件运行我的应用程序。

我发现每次执行 jetty:run 时 Maven 都坚持重新编译我的文件,这有点令人恼火。它不是最优的,因为文件已经由 Eclipse 编译(并且我正在编写 Scala,它的编译器(相对)较慢)。

我正在使用配置文件,并在我的“开发”配置文件下运行 mvn jetty:run 。

我想做的是:

<块引用> <块引用>

配置jetty插件,使其在开发配置文件下运行时跳过编译阶段。

我查看了 Maven 生命周期文档,但没有找到有关“skip.compile”标志或配置参数的任何信息。

我也尝试像这样配置 Maven,徒劳地假设它会在 maven-jetty-plugin 启动时停止重新编译。

我错了,它不起作用。但我想,也许Scala编译器就是问题所在。也许它忽略了编译的东西。

发展 maven-编译器-插件 默认测试编译 测试编译 默认编译 编译 1.6 1.6 错误的 org.mortbay.jetty jetty-maven-插件 7.2.2.v20101205 真的 发展

更新:

我将尝试专门禁用 scala 编译

I'm working with Eclipse and Maven and run my application using the Maven jetty plugin.

I find it mildly irritating that Maven insists on recompiling my files every time I execute jetty:run. It is sub-optimal, as the files have already been compiled by Eclipse (and I'm writing Scala which has a (relatively) slow compiler).

I'm using profiles, and run mvn jetty:run under my 'development' profile.

What I want to do is:

Configure the jetty plugin so that it skips the compilation phase whilst running under the development profile.

I've looked into maven lifecycle documentation but haven't found any information about a 'skip.compile' flag or configuration parameter.

I've also tried configuring Maven like so in the vain assumption that it would stop the recompile upon maven-jetty-plugin startup.

I was wrong, it did not work. But what I have thought is, perhaps the Scala compiler is the problem. Perhaps it ignores the compile stuff.

development

maven-compiler-plugin

default-testCompile
test-compile

default-compile
compile

1.6
1.6
false

org.mortbay.jetty
jetty-maven-plugin
7.2.2.v20101205

true

development

Update:

I'm going to try specifically disabling scala compilation

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

夏了南城 2024-11-11 22:43:27

终于解决了.. @RobertMunteanu

哇!好吧,我终于弄清楚我做错了什么,解决方案是创建一个开发和生产配置文件,并且对于开发配置文件,将 Scala 插件执行配置为不执行任何操作。

像这样:

<profile>
  <id>development</id>
  <build>
    <plugins>
      <plugin>
        <groupId>org.scala-tools</groupId>
        <artifactId>maven-scala-plugin</artifactId>
        <executions>
          <execution>
            <id>compile</id>
            <goals></goals>
            <phase>compile</phase>
          </execution>
          <execution>
            <id>test-compile</id>
            <goals></goals>
            <phase>test-compile</phase>
          </execution>
          <execution>
            <id>default-testCompile</id>
            <phase>test-compile</phase>
            <goals></goals>
          </execution>
          <execution>
            <id>default-compile</id>
            <phase>compile</phase>
            <goals></goals>
          </execution>
          <execution>
            <phase>process-resources</phase>
            <goals>
            </goals>
          </execution>
        </executions>
      </plugin>

Finally solved it.. @RobertMunteanu

Wow! Well I've finally figured out what I was doing wrong, the solution is to create a development and production profile, and, for the development profile configure the Scala plugin executions to do nothing.

Like so :

<profile>
  <id>development</id>
  <build>
    <plugins>
      <plugin>
        <groupId>org.scala-tools</groupId>
        <artifactId>maven-scala-plugin</artifactId>
        <executions>
          <execution>
            <id>compile</id>
            <goals></goals>
            <phase>compile</phase>
          </execution>
          <execution>
            <id>test-compile</id>
            <goals></goals>
            <phase>test-compile</phase>
          </execution>
          <execution>
            <id>default-testCompile</id>
            <phase>test-compile</phase>
            <goals></goals>
          </execution>
          <execution>
            <id>default-compile</id>
            <phase>compile</phase>
            <goals></goals>
          </execution>
          <execution>
            <phase>process-resources</phase>
            <goals>
            </goals>
          </execution>
        </executions>
      </plugin>
以可爱出名 2024-11-11 22:43:27

解决方案是设置一个环境变量:

MAVEN_OPTS="-Xdebug -Xnoagent -Djava.compiler=NONE"

以上对我有用。

在互联网的其他地方,它被描述为:

MAVEN_OPTS="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=4000,server=y,suspend=y"

The solution is to set an environmental variable of:

MAVEN_OPTS="-Xdebug -Xnoagent -Djava.compiler=NONE"

The above worked for me.

Elsewhere on the Internet it is described as:

MAVEN_OPTS="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=4000,server=y,suspend=y"
花开半夏魅人心 2024-11-11 22:43:27

经过一番研究,问题不在于jetty插件,而在于maven-compiler-plugin。增量编译中存在错误。请参阅此 stackoverflow 问题和答案: Maven 编译器插件总是检测一组源为“陈旧”

以下配置对我来说效果很好;当代码发生更改时,它允许快速重新启动 jetty,只需最少的重新编译,并且如果您已经编译过,则不会重新编译:

<plugin>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.1</version>
    <configuration>
        <source>1.6</source>
        <target>1.6</target>
        <encoding>UTF-8</encoding>
        <debug>${compile.debug}</debug>
        <useIncrementalCompilation>false</useIncrementalCompilation>
            </configuration>
</plugin>
  <plugin>
    <groupId>org.mortbay.jetty</groupId>
    <artifactId>maven-jetty-plugin</artifactId>
    <version>6.1.26</version>       
              <configuration>
                <contextPath>/</contextPath>                     
                <webAppSourceDirectory>${basedir}/src/main/webapp</webAppSourceDirectory>
                <scanIntervalSeconds>2</scanIntervalSeconds>
                <scanTargets>
                    <scanTarget>src/main/java</scanTarget>
                </scanTargets>                       
            </configuration>             
</plugin>

After some research, the problem is not with the jetty plugin, but with maven-compiler-plugin. There's a bug in the incrementalCompilation. See this stackoverflow question and answer: Maven compiler plugin always detecting a set of sources as "stale"

The following configuration works well for me; it allows for a very quick restart of jetty when code has changed with minimal recompilation, and it does not recompile if you have already compiled:

<plugin>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.1</version>
    <configuration>
        <source>1.6</source>
        <target>1.6</target>
        <encoding>UTF-8</encoding>
        <debug>${compile.debug}</debug>
        <useIncrementalCompilation>false</useIncrementalCompilation>
            </configuration>
</plugin>
  <plugin>
    <groupId>org.mortbay.jetty</groupId>
    <artifactId>maven-jetty-plugin</artifactId>
    <version>6.1.26</version>       
              <configuration>
                <contextPath>/</contextPath>                     
                <webAppSourceDirectory>${basedir}/src/main/webapp</webAppSourceDirectory>
                <scanIntervalSeconds>2</scanIntervalSeconds>
                <scanTargets>
                    <scanTarget>src/main/java</scanTarget>
                </scanTargets>                       
            </configuration>             
</plugin>
孤城病女 2024-11-11 22:43:27

如果你说这些类已经被 Eclipse 编译过,那么重新编译有两种可能的原因:

  • 你正在调用 clean 或以某种方式删除已编译的类;
  • Eclipse 的输出文件夹与 Maven 的输出文件夹不同。

因此,您需要防止删除已编译的类,或者将 Eclipse 和 Maven 配置为使用相同的输出文件夹。

If you say that the classes have already been compiled by Eclipse, there are two possible causes for recompiling:

  • you are invoking clean or deleting the compiled classes somehow;
  • the output folder for Eclipse is not the same as the output folder for Maven.

So you need to either prevent deletion of your compiled classes or configure Eclipse and Maven to use the same output folder.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文