2011-05-05 117 views
8

我正在使用Eclipse和Maven,并使用Maven码头插件运行我的应用程序。使用maven码头时:运行 - 是否可以禁用编译步骤?

我发现它轻度刺激,Maven坚持每次执行码头时重新编译我的文件:运行。这是次优的,因为这些文件已经被Eclipse编译了(并且我正在编写Scala,它有一个(相对)较慢的编译器)。

我正在使用配置文件,并运行mvn码头:在我的'开发'配置文件下运行。

我想要做的是:

配置码头插件使得它跳过编译阶段,而在发展曲线运行。

我已经研究过的Maven生命周期的文档,但还没有找到关于“skip.compile”标志或配置参数的任何信息。

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

我错了,它没有工作。但我的想法是,也许Scala编译器是问题。也许它忽略了编译的东西。

发展 Maven的编译器插件 默认testCompile 测试编译 默认编译 编译 1.6 1.6 假 org.mortbay.jetty 码头-行家-插件 7.2.2。v20101205 真正 发展

更新:

我要去尝试专门禁用斯卡拉编译

+0

据我所知,您可以配置码头插件周期性,所以你扫描不需要停止码头...并在Eclipse中进行更改...深入了解maven-jetty插件.. – khmarbaise 2011-05-05 11:41:35

+0

khmarbaise,我已经禁用扫描,因为我正在使用jrebel进行编译。我也深入了解插件,否则我不会在这里。它需要的是禁用码头的fork编译阶段:运行目标 – 2011-05-05 11:56:47

回答

-1

如果你说的类已经被编译Eclipse中有两种可能的重新编译原因:

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

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

+1

不,这不是原因。原因是jetty:run目标在每次启动时都要进行编译。我已经解决了这个问题,现在将发布解决方案。 – 2011-05-05 16:07:01

2

的解决方法是设置环境变量:

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

以上为我工作。

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

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

我的代码,编译,测试,循环都不太可以接受! – 2011-05-17 20:21:50

+0

虽然这似乎工作,但事实上并没有这样做。回到绘图板。 – 2011-05-18 07:45:23

+0

另一部分是远程调试器连接 – 2012-02-16 20:17:57

9

终于解决了吧.. @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> 
0

经过一番研究,这个问题是不是与码头插件,但与Maven编译器的插件。 incrementalCompilation中存在一个错误。看到这个stackoverflow问题和答案:Maven compiler plugin always detecting a set of sources as "stale"

以下配置适合我;它允许码头非常快速重新启动时,代码以最小的重新编译改变,如果你已经编译它不会重新编译:

<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> 
相关问题