Reputation: 3783
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
Upvotes: 8
Views: 5211
Reputation: 1706
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>
Upvotes: 0
Reputation: 3783
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>
Upvotes: 9
Reputation: 3783
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"
Upvotes: 2
Reputation: 68308
If you say that the classes have already been compiled by Eclipse, there are two possible causes for recompiling:
clean
or deleting the compiled classes somehow;So you need to either prevent deletion of your compiled classes or configure Eclipse and Maven to use the same output folder.
Upvotes: -1