[MAVEN_INCREMENTAL_BUILD-12] Plugin looks for a resources directory in POM modules where it is not necessary Created: 25/Jul/11  Updated: 06/Mar/12  Resolved: 27/Jan/12

Status: Resolved
Project: maven-incremental-build
Component/s: modification detection
Affects Version/s: 1.4
Fix Version/s: 1.5

Type: Bug Priority: Critical
Reporter: yohanliyanage Assignee: vsellier
Resolution: Fixed Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Ubuntu 11.04, Maven 2.2.1


I am running Maven Incremental Build on a multi-module project. The parent module does not have a src/resources or src/java directory because it is a POM module.

When the plugin executes, it says that src/resources is not found also also states that a resource has been deleted, and therefore it cleans the parent module, which leads to a full build instead of an incremental build.

Output from Plugin :

[INFO] ------------------------------------------------------------------------
[INFO] Building XXXX
[INFO] task-segment: [install]
[INFO] ------------------------------------------------------------------------
[INFO] [incremental-build:incremental-build

{execution: default}

[INFO] Verifying module descriptor ...
[INFO] Verifying parent modules...
[INFO] Verifying resources...
[INFO] Resources directory does not exist : /home/yohan/workspace/XXXX/src/main/resources
[INFO] A resource was deleted, module have to be cleaned
[INFO] Deleting /home/yohan/workspace/XXXX/target
[INFO] [site:attach-descriptor

{execution: default-attach-descriptor}

[INFO] [install:install

{execution: default-install}

[INFO] Installing /home/yohan/workspace/XXX/pom.xml to /home/yohan/.m2/repository/XXXX/0.0.1-SNAPSHOT/XXXX-0.0.1-SNAPSHOT.pom

Comment by mrleit [ 26/Jan/12 ]

I was looking at this same problem, and because it was occurring at the top level of our hierarchy it caused the entire structure to rebuild.

I checked out trunk and I believe I isolated and fixed the problem, which was that the resourcesList file was never created due to an incorrect logic statement.

In IncrementalBuildMojo.java in resourcesUpdated() at the end...

	if (previousResources.isEmpty()) {
		getLog().info("A resource was deleted, module have to be cleaned");
		return true;
	try {
	} catch (IOException e) {
		getLog().warn("Error saving resource files list", e);
		return true;
	return false;

where it checks that previousResources is empty. I believe it should be checking that it is not empty !isEmpty(). PreviousResources is the list of resources - (minus) the current files in the resource directory. If anything is left in this list, then something was deleted.

After this is fixed, the method correctly writes the actual resources file.

This also causes the resource unit test to fail... and I believe it never worked properly anyway.

I've Ignored it for now.

Behaviour of the plugin appears to be as expected now.

Comment by mrleit [ 06/Mar/12 ]

I have been testing the 1.6 release and have noted that there seems to still be a slight issue with testResource directory.

The project is being cleaned in much the same way as previously because of the src/resource directory, however this time it is caused by test/resource.

Here is the log illustrating the problem.

[DEBUG] Last source modification : 1330697787162
[DEBUG] Target directory : xxx\target\classes
[DEBUG] Scanning output directory...
[DEBUG] Target files : [ xxx ]
[DEBUG] Last target modification date : 1331031355849
[DEBUG] No timestamp changes detected.
[DEBUG] Saving source list
[DEBUG] Saving file xxx\target\test-classes\testsList ...
[INFO] Verifying tests resources...
[INFO] Verifying test resources...
[DEBUG] Using file : xxx\target\testResourcesList
[DEBUG] Previous file xxx\target\testResourcesList not found.
[DEBUG] Using file : xxx\target\testResourcesList
[DEBUG] Resources excludes : []
[DEBUG] Resources includes : []
[INFO] Resources directory does not exist : xxx\src\test\resources
[DEBUG] Saving file xxx\target\testResourcesList ...
[DEBUG] test update detected : true
[DEBUG] Module updated, cleaning module
[INFO] Deleting xxx\target
[DEBUG] Saving timestamps..
[DEBUG] Saving file xxx\target\timestamp ...

I have manually added an empty resource directory to test folder to workaround this issue. But we have dozens of projects that don't have and don't require this directory.

Generated at Sun Feb 19 18:40:21 UTC 2017 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.