Following (simplified) build.gradle
apply plugin: 'java'
// two jars from here:
// http://search.maven.org/remotecontent?filepath=org/glassfish/javax.faces/2.1.21/javax.faces-2.1.21.jar
// and here:
// http://search.maven.org/remotecontent?filepath=org/glassfish/javax.faces/2.1.21/javax.faces-2.1.21-sources.jar
dependencies {
compile fileTree(dir: 'lib', include: '**/*.jar')
}
The lib folder contains two jars from javax.faces. The binary and the sources. Also, in src/test/java/de/rob is a test class (with no useful test):
package de.rob;
import javax.faces.context.FacesContext;
public class SourcesTest {
public void testContext() {
//FacesContext.getCurrentInstance();
}
}
If you now do a “gradle test” you get swamped by “cannot find symbol” messages, e.g:
C:\Users\Robert\Documents\gradlesources\lib\javax.faces-2.1.21-sources.jar(javax/faces/component/ComponentStateHelper.java):192: error: cannot find symbol
ValueExpression ve = component.getValueExpression(key.toString());
^
symbol:
class ValueExpression
location: class ComponentStateHelper
Now, for a second test, go into the lib folder and remove the sources jar and repeat “gradle test”. Everything works fine now.
It took me several hours to find the cause of this in a bigger project and I’m not sure if I can prevent sources jars from leaking into libs folders.
Question: Why does gradle get irritated by a sources jar which shouldn’t be touched anyway? Is this correct behaviour?