I'm new with Gradle, so there's a chance that I am missing something obvious here. I am working on using Gradle for automated building of our projects. I've tackled most of them, but one is causing me unending trouble. Since this is for my company, I can't share any real code, but I will do my best to provide realistic pseudo-code.
I am attempting to compile a web application with a flex front-end and java back-end. Right now, I am focused solely on creating a .war file with the java in it, then I will move into the flex compilation. When I run the following build.gradle script, it gives me countless "cannot find symbol" errors.
apply plugin: 'eclipse'
apply plugin: 'war'
sourceCompatibility = 1.6
repositories {
mavenCentral()
}
sourceSets.main.java.srcDir 'src'
sourceSets.main.resources.srcDir 'src'
webAppDirName = "WebContent"
war.archiveName "Gradle_test.war"
dependencies {
compile fileTree(dir: 'WebContent/WEB-INF/lib', include: '*.jar')
providedCompile 'org.apache.tomcat:catalina:6.0.13'
providedCompile 'org.apache.tomcat:dbcp:6.0.13'
}
An example of the errors that were occurring (with fake package and class names):
/Users/user/Documents/eclipse/ProjectName/src/com/companyName/teamName/projectName/core/release/subProjectName/projectVersion/RenamedObject.java:385: cannot find symbol
symbol : class OtherObject
location: class com.companyName.teamName.projectName.core.release.subProjectName.projectVersion.RenamedObject
public class InnerClass extends OtherObject implements Indexable<String>, Serializable {
The class InnerClass is declared within the RenamedObject.java file along with the RenamedObject class. The symbol it cannot find, OtherObject, is not from a .jar. It is a source file stored at /Users/user/Documents/eclipse/ProjectName/src/com/companyName/teamName/projectName/core/release/subProjectName/projectVersion/superTypes/OtherObject.java
. The object is imported at the top of RenamedObject.java and can be built and run properly via eclipse without any special settings. These errors occur during the :compileJava task after executing gradle war
from terminal.
Is there any reason that Gradle would have an issue with handling source imports from a sub-package like this? Am I just doing something wrong? Let me know if there is any more info that can help and I will provide it if I can.
EDIT: I got it to work. All 130 of the errors were resolved with one change. If I add the fully qualified package name to OtherObject in the extends, so it looks like this:
public class InnerClass extends com.companyName.teamName.projectName.core.release.subProjectName.projectVersion.superTypes.OtherObject implements Indexable<String>, Serializable {
That one change made it all work, but I still don't understand the reason. That is not the only reference to OtherObject in the project and it is not the only place that an inner class extends a class defined in another source package.