I have a project that looks like this.
root
build.gradle
settings.gradle
project1
build.gradle
project2
build.gradle
project3
build.gradle
project4
build.gradle
settings.gradle looks like this.
include ':project1', ':project2', ':project3', ':project4'
build.gradle (from root)
apply plugin: 'java'
apply plugin: 'eclipse'
repositories {
mavenCentral()
}
dependencies {
compile project(':project1')
compile project(':project2')
compile project(':project3')
compile project(':project4')
}
So basically, I want 'project1' to be built first before project2, 3, 4, because it needs to download our internal dependency(jar and some schema files) so that project2, 3 and 4 will be able to extract artifacts from the schema files(from project1).
But when I run it, i see standard output from project2 and 3 printed first before project1 runs.
Especially project2 contains many tasks(type: JavaExec) which run this type of arguments.
main = 'org.apache.xmlbeans.impl.tool.SchemaCompiler'
classpath "${BUILDROOT}/project1/${COMMON_DENEPDENCY_FILE}"
args "-src", "${projectDir}/src/main/java", "-d", "build/generated", "-srconly", "${projectDir}/xml/schema/example1.xsd", "${projectDir}/xml/schema/example1.xsdconfig"
One of the tasks looks like this. I have several tasks that look like this in project2. So project1 has to be fully built before project2 and project3 run.
build.gradle from project2
task xmlbeansExample2(dependsOn: xmlbeansExample1, type: JavaExec) {
println "Example2 is running"
main = 'org.apache.xmlbeans.impl.tool.SchemaCompiler'
classpath "${BUILDROOT}/common/${COMMON_DENEPDENCY_FILE}"
args "-src", "${projectDir}/src/main/java", "-d", "build/generated", "-srconly", "${projectDir}/xml/schema/example2.xsd", "${projectDir}/xml/schema/example2.xsdconfig"
println "Example2 is done"
}
task handleSchema(dependsOn: ['xmlbeansExample1', 'xmlbeansExample2'])
build.dependsOn handleSchema, jar
When I run 'gradle build' from the root or project2, I see the printout from project2 first.
Is there something wrong with my layout?
My team is migrating from Ant to Gradle, but gradle seems a little different from Ant execution. Maybe I am little misunderstood about the gradle.