Building Maven projects in Eclipse

Maven and Eclipse have a history. In the early days, the Maven integration in Eclipse was considered sub-par. I’ve read statements that IntelliJ offers way better support for Maven projects. But then, I’ve also read statements that Eclipse offers way better support for Maven projects (than IntelliJ). It seems to depend on the versions being reviewed.

Today, m2e offers a very good integration with Maven. Some of the “features”, however, take a while to fully understand. Let’s start with the fundamental building blocks..

Eclipse Builders

In a typical Maven project you’ll find three builders defined in Project → Properties → Builders

  • Validation
  • Maven Builder
  • Java Builder

Build strategies

Eclipse internally knows a few different build types:

  • FULL_BUILD
  • INCREMENTAL_BUILD
  • AUTO_BUILD

These build types can also be build triggers. If an INCREMENTAL_BUILD has no delta, it will trigger a FULL_BUILD. There is also a build trigger CLEAN_BUILD, which is only a trigger but not a build type.

Relevant Eclipse Settings

Eclipse has plenty of settings, but here are some which are relevant to understanding how m2e works:

General → Workspace → Build

  • Max iterations when building with cycle
  • Max simultaneous project builds

Maven (via Window → Preferences)

  • Automatically update Maven projects configuration (experimental)

Maven (both globally on Window → Preferences and per project in the properties)

  • Annotation Processing (Automatically / Delegate to plugins / Off)
  • Lifecycle Mappings

Here’s the workspace default lifecycle mapping on my computer:

<?xml version="1.0" encoding="UTF-8"?>
<lifecycleMappingMetadata>
	<pluginExecutions>
		<pluginExecution>
			<pluginExecutionFilter>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-dependency-plugin</artifactId>
				<versionRange>2.10</versionRange>
				<goals>
					<goal>copy-dependencies</goal>
					<goal>unpack-dependencies</goal>
					<goal>unpack</goal>
					<goal>copy</goal>
				</goals>
			</pluginExecutionFilter>
			<action>
				<ignore />
			</action>
		</pluginExecution>
		<pluginExecution>
			<pluginExecutionFilter>
				<groupId>org.eclipse.rcptt</groupId>
				<artifactId>rcptt-maven-plugin</artifactId>
				<versionRange>2.0.0</versionRange>
				<goals>
					<goal>resources</goal>
					<goal>execute</goal>
				</goals>
			</pluginExecutionFilter>
			<action>
				<ignore />
			</action>
		</pluginExecution>
		<pluginExecution>
			<pluginExecutionFilter>
				<groupId>org.apache.felix</groupId>
				<artifactId>maven-bundle-plugin</artifactId>
				<versionRange>3.0.0</versionRange>
				<goals>
					<goal>manifest</goal>
				</goals>
			</pluginExecutionFilter>
			<action>
				<ignore />
			</action>
		</pluginExecution>
		<pluginExecution>
			<pluginExecutionFilter>
				<groupId>org.jacoco</groupId>
				<artifactId>jacoco-maven-plugin</artifactId>
				<versionRange>0.7.2.201409121644</versionRange>
				<goals>
					<goal>instrument</goal>
				</goals>
			</pluginExecutionFilter>
			<action>
				<ignore />
			</action>
		</pluginExecution>
		<pluginExecution>
			<pluginExecutionFilter>
				<groupId>com.inocybe.api</groupId>
				<artifactId>sdndocs-maven-plugin</artifactId>
				<versionRange>0.1.0</versionRange>
				<goals>
					<goal>generate-webhelp</goal>
				</goals>
			</pluginExecutionFilter>
			<action>
				<ignore />
			</action>
		</pluginExecution>
		<pluginExecution>
			<pluginExecutionFilter>
				<groupId>org.asciidoctor</groupId>
				<artifactId>asciidoctor-maven-plugin</artifactId>
				<versionRange>0.1.4</versionRange>
				<goals>
					<goal>process-asciidoc</goal>
				</goals>
			</pluginExecutionFilter>
			<action>
				<ignore />
			</action>
		</pluginExecution>
		<pluginExecution>
			<pluginExecutionFilter>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-pmd-plugin</artifactId>
				<versionRange>3.6</versionRange>
				<goals>
					<goal>cpd-check</goal>
				</goals>
			</pluginExecutionFilter>
			<action>
				<ignore />
			</action>
		</pluginExecution>
		<pluginExecution>
			<pluginExecutionFilter>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-antrun-plugin</artifactId>
				<versionRange>1.8</versionRange>
				<goals>
					<goal>run</goal>
				</goals>
			</pluginExecutionFilter>
			<action>
				<ignore />
			</action>
		</pluginExecution>
		<pluginExecution>
			<pluginExecutionFilter>
				<groupId>org.opendaylight.yangtools</groupId>
				<artifactId>yang-maven-plugin</artifactId>
				<versionRange>1.1.0-SNAPSHOT</versionRange>
				<goals>
					<goal>generate-sources</goal>
				</goals>
			</pluginExecutionFilter>
			<action>
				<ignore />
			</action>
		</pluginExecution>
	</pluginExecutions>
</lifecycleMappingMetadata> 

And here’s the lifecycle mapping of the funnel.travel server project

<?xml version="1.0" encoding="UTF-8"?>
<lifecycleMappingMetadata>
  <lifecycleMappings>
    <lifecycleMapping>
      <pluginExecutions>
        <pluginExecution>
          <pluginExecutionFilter>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-clean-plugin</artifactId>
            <versionRange>2.5</versionRange>
            <goals>
              <goal>clean</goal>
            </goals>
          </pluginExecutionFilter>
          <ignore />
          <comment>source: uninteresting</comment>
        </pluginExecution>
        <pluginExecution>
          <pluginExecutionFilter>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-resources-plugin</artifactId>
            <versionRange>[2.4,)</versionRange>
            <goals>
              <goal>testResources</goal>
              <goal>copy-resources</goal>
              <goal>resources</goal>
            </goals>
          </pluginExecutionFilter>
          <action>
            <execute>
              <runOnIncremental>true</runOnIncremental>
            </execute>
          </action>
          <comment>source: default</comment>
        </pluginExecution>
        <pluginExecution>
          <pluginExecutionFilter>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <versionRange>[2.0,)</versionRange>
            <goals>
              <goal>testCompile</goal>
              <goal>compile</goal>
            </goals>
            <parameters>
              <compilerId>javac</compilerId>
            </parameters>
          </pluginExecutionFilter>
          <action>
            <configurator>
              <id>org.eclipse.m2e.jdt.javaConfigurator</id>
            </configurator>
          </action>
          <comment>source: extension(org.eclipse.m2e.jdt_1.8.3.20180227-2137),extension(org.eclipse.m2e.wtp_1.3.3.20170823-1905),extension(org.eclipse.m2e.wtp.jpa_1.3.3.20170823-1905),extension(org.springframework.ide.eclipse.maven_3.9.4.201804120850-RELEASE)</comment>
        </pluginExecution>
        <pluginExecution>
          <pluginExecutionFilter>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <versionRange>[2.0,)</versionRange>
            <goals>
              <goal>testCompile</goal>
              <goal>compile</goal>
            </goals>
          </pluginExecutionFilter>
          <action>
            <configurator>
              <id>org.maven.ide.eclipse.configuration.wtp.java.unsupportedDependencyTypeConfigurator</id>
            </configurator>
          </action>
          <comment>source: extension(org.eclipse.m2e.jdt_1.8.3.20180227-2137),extension(org.eclipse.m2e.wtp_1.3.3.20170823-1905),extension(org.eclipse.m2e.wtp.jpa_1.3.3.20170823-1905),extension(org.springframework.ide.eclipse.maven_3.9.4.201804120850-RELEASE)</comment>
        </pluginExecution>
        <pluginExecution>
          <pluginExecutionFilter>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <versionRange>[2.0,)</versionRange>
            <goals>
              <goal>compile</goal>
            </goals>
          </pluginExecutionFilter>
          <action>
            <configurator>
              <id>org.eclipse.m2e.wtp.jpa.configurator.jdt</id>
            </configurator>
          </action>
          <comment>source: extension(org.eclipse.m2e.jdt_1.8.3.20180227-2137),extension(org.eclipse.m2e.wtp_1.3.3.20170823-1905),extension(org.eclipse.m2e.wtp.jpa_1.3.3.20170823-1905),extension(org.springframework.ide.eclipse.maven_3.9.4.201804120850-RELEASE)</comment>
        </pluginExecution>
        <pluginExecution>
          <pluginExecutionFilter>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <versionRange>[2.0,)</versionRange>
            <goals>
              <goal>testCompile</goal>
              <goal>compile</goal>
            </goals>
          </pluginExecutionFilter>
          <action>
            <configurator>
              <id>com.springsource.sts.ide.maven.core.springProjectConfigurator</id>
            </configurator>
          </action>
          <comment>source: extension(org.eclipse.m2e.jdt_1.8.3.20180227-2137),extension(org.eclipse.m2e.wtp_1.3.3.20170823-1905),extension(org.eclipse.m2e.wtp.jpa_1.3.3.20170823-1905),extension(org.springframework.ide.eclipse.maven_3.9.4.201804120850-RELEASE)</comment>
        </pluginExecution>
        <pluginExecution>
          <pluginExecutionFilter>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <versionRange>[2.0,)</versionRange>
            <goals>
              <goal>testCompile</goal>
              <goal>compile</goal>
            </goals>
          </pluginExecutionFilter>
          <action>
            <configurator>
              <id>org.maven.ide.eclipse.configuration.wtp.utility.configurator</id>
            </configurator>
          </action>
          <comment>source: extension(org.eclipse.m2e.jdt_1.8.3.20180227-2137),extension(org.eclipse.m2e.wtp_1.3.3.20170823-1905),extension(org.eclipse.m2e.wtp.jpa_1.3.3.20170823-1905),extension(org.springframework.ide.eclipse.maven_3.9.4.201804120850-RELEASE)</comment>
        </pluginExecution>
        <pluginExecution>
          <pluginExecutionFilter>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <versionRange>[2.0,)</versionRange>
            <goals>
              <goal>testCompile</goal>
              <goal>compile</goal>
            </goals>
          </pluginExecutionFilter>
          <action>
            <configurator>
              <id>org.maven.ide.eclipse.configuration.wtp.webfragment.configurator</id>
            </configurator>
          </action>
          <comment>source: extension(org.eclipse.m2e.jdt_1.8.3.20180227-2137),extension(org.eclipse.m2e.wtp_1.3.3.20170823-1905),extension(org.eclipse.m2e.wtp.jpa_1.3.3.20170823-1905),extension(org.springframework.ide.eclipse.maven_3.9.4.201804120850-RELEASE)</comment>
        </pluginExecution>
        <pluginExecution>
          <pluginExecutionFilter>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-resources-plugin</artifactId>
            <versionRange>[2.4,)</versionRange>
            <goals>
              <goal>testResources</goal>
              <goal>copy-resources</goal>
              <goal>resources</goal>
            </goals>
          </pluginExecutionFilter>
          <action>
            <execute>
              <runOnIncremental>true</runOnIncremental>
            </execute>
          </action>
          <comment>source: default</comment>
        </pluginExecution>
        <pluginExecution>
          <pluginExecutionFilter>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <versionRange>[2.0,)</versionRange>
            <goals>
              <goal>testCompile</goal>
              <goal>compile</goal>
            </goals>
            <parameters>
              <compilerId>javac</compilerId>
            </parameters>
          </pluginExecutionFilter>
          <action>
            <configurator>
              <id>org.eclipse.m2e.jdt.javaConfigurator</id>
            </configurator>
          </action>
          <comment>source: extension(org.eclipse.m2e.jdt_1.8.3.20180227-2137),extension(org.eclipse.m2e.wtp_1.3.3.20170823-1905),extension(org.springframework.ide.eclipse.maven_3.9.4.201804120850-RELEASE)</comment>
        </pluginExecution>
        <pluginExecution>
          <pluginExecutionFilter>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <versionRange>[2.0,)</versionRange>
            <goals>
              <goal>testCompile</goal>
              <goal>compile</goal>
            </goals>
          </pluginExecutionFilter>
          <action>
            <configurator>
              <id>org.maven.ide.eclipse.configuration.wtp.java.unsupportedDependencyTypeConfigurator</id>
            </configurator>
          </action>
          <comment>source: extension(org.eclipse.m2e.jdt_1.8.3.20180227-2137),extension(org.eclipse.m2e.wtp_1.3.3.20170823-1905),extension(org.springframework.ide.eclipse.maven_3.9.4.201804120850-RELEASE)</comment>
        </pluginExecution>
        <pluginExecution>
          <pluginExecutionFilter>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <versionRange>[2.0,)</versionRange>
            <goals>
              <goal>testCompile</goal>
              <goal>compile</goal>
            </goals>
          </pluginExecutionFilter>
          <action>
            <configurator>
              <id>com.springsource.sts.ide.maven.core.springProjectConfigurator</id>
            </configurator>
          </action>
          <comment>source: extension(org.eclipse.m2e.jdt_1.8.3.20180227-2137),extension(org.eclipse.m2e.wtp_1.3.3.20170823-1905),extension(org.springframework.ide.eclipse.maven_3.9.4.201804120850-RELEASE)</comment>
        </pluginExecution>
        <pluginExecution>
          <pluginExecutionFilter>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <versionRange>[2.0,)</versionRange>
            <goals>
              <goal>testCompile</goal>
              <goal>compile</goal>
            </goals>
          </pluginExecutionFilter>
          <action>
            <configurator>
              <id>org.maven.ide.eclipse.configuration.wtp.utility.configurator</id>
            </configurator>
          </action>
          <comment>source: extension(org.eclipse.m2e.jdt_1.8.3.20180227-2137),extension(org.eclipse.m2e.wtp_1.3.3.20170823-1905),extension(org.springframework.ide.eclipse.maven_3.9.4.201804120850-RELEASE)</comment>
        </pluginExecution>
        <pluginExecution>
          <pluginExecutionFilter>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <versionRange>[2.0,)</versionRange>
            <goals>
              <goal>testCompile</goal>
              <goal>compile</goal>
            </goals>
          </pluginExecutionFilter>
          <action>
            <configurator>
              <id>org.maven.ide.eclipse.configuration.wtp.webfragment.configurator</id>
            </configurator>
          </action>
          <comment>source: extension(org.eclipse.m2e.jdt_1.8.3.20180227-2137),extension(org.eclipse.m2e.wtp_1.3.3.20170823-1905),extension(org.springframework.ide.eclipse.maven_3.9.4.201804120850-RELEASE)</comment>
        </pluginExecution>
        <pluginExecution>
          <pluginExecutionFilter>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <versionRange>2.19</versionRange>
            <goals>
              <goal>test</goal>
            </goals>
          </pluginExecutionFilter>
          <ignore />
          <comment>source: uninteresting</comment>
        </pluginExecution>
        <pluginExecution>
          <pluginExecutionFilter>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <versionRange>[2.0.1,)</versionRange>
            <goals>
              <goal>war</goal>
            </goals>
          </pluginExecutionFilter>
          <action>
            <configurator>
              <id>org.maven.ide.eclipse.configuration.wtp.configurator</id>
            </configurator>
          </action>
          <comment>source: extension(org.eclipse.m2e.wtp_1.3.3.20170823-1905),extension(org.eclipse.m2e.wtp.jsf_1.3.3.20170823-1905),extension(org.eclipse.m2e.wtp.jaxrs_1.3.3.20170823-1905)</comment>
        </pluginExecution>
        <pluginExecution>
          <pluginExecutionFilter>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <versionRange>[1.0,)</versionRange>
            <goals>
              <goal>war</goal>
            </goals>
          </pluginExecutionFilter>
          <action>
            <configurator>
              <id>org.eclipse.m2e.wtp.jsf.configurator</id>
            </configurator>
          </action>
          <comment>source: extension(org.eclipse.m2e.wtp_1.3.3.20170823-1905),extension(org.eclipse.m2e.wtp.jsf_1.3.3.20170823-1905),extension(org.eclipse.m2e.wtp.jaxrs_1.3.3.20170823-1905)</comment>
        </pluginExecution>
        <pluginExecution>
          <pluginExecutionFilter>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <versionRange>[2.0.1,)</versionRange>
            <goals>
              <goal>war</goal>
            </goals>
          </pluginExecutionFilter>
          <action>
            <configurator>
              <id>org.maven.ide.eclipse.configuration.wtp.overlay.configurator</id>
            </configurator>
          </action>
          <comment>source: extension(org.eclipse.m2e.wtp_1.3.3.20170823-1905),extension(org.eclipse.m2e.wtp.jsf_1.3.3.20170823-1905),extension(org.eclipse.m2e.wtp.jaxrs_1.3.3.20170823-1905)</comment>
        </pluginExecution>
        <pluginExecution>
          <pluginExecutionFilter>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <versionRange>[2.0.1,)</versionRange>
            <goals>
              <goal>war</goal>
            </goals>
          </pluginExecutionFilter>
          <action>
            <configurator>
              <id>org.maven.ide.eclipse.configuration.wtp.warmanifest.configurator</id>
            </configurator>
          </action>
          <comment>source: extension(org.eclipse.m2e.wtp_1.3.3.20170823-1905),extension(org.eclipse.m2e.wtp.jsf_1.3.3.20170823-1905),extension(org.eclipse.m2e.wtp.jaxrs_1.3.3.20170823-1905)</comment>
        </pluginExecution>
        <pluginExecution>
          <pluginExecutionFilter>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <versionRange>[1.0,)</versionRange>
            <goals>
              <goal>war</goal>
            </goals>
          </pluginExecutionFilter>
          <action>
            <configurator>
              <id>org.eclipse.m2e.wtp.jaxrs.configurator</id>
            </configurator>
          </action>
          <comment>source: extension(org.eclipse.m2e.wtp_1.3.3.20170823-1905),extension(org.eclipse.m2e.wtp.jsf_1.3.3.20170823-1905),extension(org.eclipse.m2e.wtp.jaxrs_1.3.3.20170823-1905)</comment>
        </pluginExecution>
        <pluginExecution>
          <pluginExecutionFilter>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <versionRange>1.5.12.RELEASE</versionRange>
            <goals>
              <goal>repackage</goal>
            </goals>
          </pluginExecutionFilter>
          <ignore />
          <comment>source: uninteresting</comment>
        </pluginExecution>
        <pluginExecution>
          <pluginExecutionFilter>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>license-maven-plugin</artifactId>
            <versionRange>1.16</versionRange>
            <goals>
              <goal>aggregate-add-third-party</goal>
              <goal>check-file-header</goal>
              <goal>license-list</goal>
              <goal>update-project-license</goal>
              <goal>comment-style-list</goal>
              <goal>download-licenses</goal>
              <goal>add-third-party</goal>
              <goal>update-file-header</goal>
            </goals>
          </pluginExecutionFilter>
          <action>
            <ignore />
          </action>
          <comment>source: maven-plugin(org.codehaus.mojo:license-maven-plugin:maven-plugin:1.16:runtime)</comment>
        </pluginExecution>
        <pluginExecution>
          <pluginExecutionFilter>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-install-plugin</artifactId>
            <versionRange>2.5.2</versionRange>
            <goals>
              <goal>install</goal>
            </goals>
          </pluginExecutionFilter>
          <ignore />
          <comment>source: uninteresting</comment>
        </pluginExecution>
        <pluginExecution>
          <pluginExecutionFilter>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-deploy-plugin</artifactId>
            <versionRange>2.8</versionRange>
            <goals>
              <goal>deploy</goal>
            </goals>
          </pluginExecutionFilter>
          <ignore />
          <comment>source: uninteresting</comment>
        </pluginExecution>
        <pluginExecution>
          <pluginExecutionFilter>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-site-plugin</artifactId>
            <versionRange>3.3</versionRange>
            <goals>
              <goal>site</goal>
            </goals>
          </pluginExecutionFilter>
          <ignore />
          <comment>source: uninteresting</comment>
        </pluginExecution>
      </pluginExecutions>
    </lifecycleMapping>
  </lifecycleMappings>
</lifecycleMappingMetadata>

Build now

Pull newest code first

When pulling code from the repository, Eclipse will inadvertently find changed sources (unless you’re up-to-date, of course). For the sake of this blog, let’s assume part of that pull just updated at least one of your pom.xml.

As our pom.xml has changed, Eclipse generates a lifecycle mapping based on the new pom.xml, and compares the result to the previous lifecycle mapping. If the two are logically different, Eclipse raises the error:

Project configuration is not up-to-date with pom.xml

The lifecycle mappings are a derivative from configuration at various levels:

  1. Project pom.xml
  2. Parent pom.xml
  3. Workspace preferences (Preferences → Maven → Lifecycle Mapping)
  4. In the Maven plugin itself

The error message above means that Eclipse will build the project differently compared to the previous pom.xml, and is asking the user to update the project configuration (Project context → Maven → Update project). Running that command will update Eclipse’s .project, .classpath and .settings files to reflect the configuration found in the pom.xml.

If the “Automatically update Maven projects configuration (experimental)” option mentioned above is activated, all this happens automatically and in the background.

A typical example of how m2e influences the Eclipse project files is that in Maven projects resources are marked as excluding=”**” in .classpath, so that the Java Builder won’t touch them. Instead, the Maven Builder will handle resources, respecting the pom.xml configuration such as filtering.

So what is this lifecycle mapping

For each configured plugin, m2e will evaluate which action is required on build. These pluginExecution actions are defined per groupId + artifactId + versionRange and one or several Maven goals. Possible actions are:

  • “ignore” .. simply don’t execute the Maven plugin at all
  • “execute” .. run the Maven plugin without any Eclipse influence. This is seen as a last resort, as Eclipse might react erratically to the result of the Maven build
  • “delegate” .. to a project configurator (<configurator> allows tight integration with other Eclipse tools)

In the lifecycle mapping for funnel.travel listed above, one finds that

  • maven-resources-plugin is executed on the ‘testResources’, ‘copy-resources’ and ‘resources’ goals
  • maven-compiler-plugin however is handed over to a series of configurators, the first being “org.eclipse.m2e.jdt.javaConfigurator”. A bit surprisingly, the compilerId is set to javac, which tells the
    javaConfigurator to use javac (as opposed to the superior Eclipse compiler, which would have compilerId = eclipse)

Here again we see the basic approach of Eclipse doing compiling, and delegating resource handling to Maven.

Build workspace

So now that the project configuration has been sorted out, the actual workspace build starts.

First thing of interest in the log is

Activator$ResourceRefreshJob(Git Repository Refresh): Auto-Build requested

So our GIT pull is triggering an Auto-Build. There is no declaration of whether this needs to be an INCREMENTAL or FULL build. In the following lines, we see that Eclipse starts delta computation to run an INCREMENTAL build

Checking if need to build. Starting delta computation between: ElementTree(123) and ElementTree(137)
...
JavaBuilder(funnel-server; []) needs building because of changes in:
funnel-server
JavaBuilder: Starting build of funnel-server @ Mon Mar 04 10:11:09 CET 2019
JavaBuilder: Found source delta for: funnel-server
JavaBuilder: Clearing last state : State for funnel-server (#1 @ Mon Mar 04 10:01:39 CET 2019)
INCREMENTAL build

The incremental builds are typically very efficient.

Eventually, however, reality kicks in. Our GIT pull has updated a few SNAPSHOTs, and now Eclipse reports:

JavaBuilder: New location: Classpath jar file C:\Users\niederberger.m2\repository\ch\want\funnel\extensions\magical-extension\0.0.9-SNAPSHOT\magical-extension-0.0.9-SNAPSHOT.jar
!= old location: Classpath jar file C
C:\Users\niederberger.m2\repository\ch\want\funnel\extensions\magical-extension\0.0.9-SNAPSHOT\magical-extension-0.0.9-SNAPSHOT.jar
...
JavaBuilder: Performing full build since classpath has changed
JavaBuilder: Clearing last state : State for funnel-server (#1 @ Thu Feb 28 07:53:11 CET 2019)
FULL build

Now we’re in trouble. ‘magical-extension’ is a project in Eclipse, but it’s closed. So workspace resolution can’t help with an incremental build, Eclipse must assume that the SNAPSHOT has changed significantly. As no delta is available, a full build is triggered.

From here on, it depends on the project structure. All projects with the SNAPSHOT dependency will experience a full build. Projects depending on these projects will get an incremental build. Eclipse will build these based on dependencies, and whatever is defined in Preferences → General → Workspace → Build → “Project build order”.

What to look out for

  • The order of Eclipse Builders matters. Unless you know what you’re doing, the order should be
    1. Validation
    2. JavaBuilder
    3. MavenBuilder
  • It might be worthwhile keeping Eclipse projects open for which SNAPSHOT dependencies often change. This allows workspace resolution to work with build deltas.
  • A large number of intertwined projects will lead to long build times, as each project build means dependencies need to be rebuilt. For an incremental build this can be pretty fast, but once a full build is running this can be several minutes.

Resources


In the process of developing funnel.travel, a corporate post-booking travel management tool, I’m sharing some hopefully useful insights into Angular 6, Spring Boot, jOOQ, or any other technology we’ll be using.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s