How to support multiple projects in multiple languages (Java and Scala) in Gradle? -


i trying convert our antiquated ant build gradle. project contains java 50 sub-projects , 10 scala sub-projects. java projects contain java , scala projects scala. each project getting built java scala slowing down our build considerably.

i want place common logic in root build.gradle file possible looks this:

subprojects {     apply plugin: 'java'     apply plugin: 'scala'      sourcecompatibility=1.7     targetcompatibility=1.7      sourcesets {         main {             scala {                 srcdir 'src'             }             java {                 srcdir 'src'             }         }         test {             scala {                 srcdir 'test'             }             java {                 srcdir 'test'             }         }     }      repositories {         mavencentral()     }      dependencies {         scalatools "org.scala-lang:scala-compiler:2.9.3"         compile "org.scala-lang:scala-library:2.9.3"     }      // use sbt compiler (not scalac ant task)     tasks.withtype(scalacompile) {         scalacompileoptions.useant = false     }      task showcompileclasspath << {        sourcesets.main.compileclasspath.each { println }     }      test {         systemproperty "user.dir", projectdir     } } 

when run build following output, notice :esb-server:compilejava , :esb-server:compilescala contain same warnings, classes being built twice. notice every other project contains compilejava , compilescala

:common:assemble :esb-server:compilejava note: input files use or override deprecated api. note: recompile -xlint:deprecation details. :esb-server:compilescala note: input files use or override deprecated api. note: recompile -xlint:deprecation details. :esb-server:processresources up-to-date :esb-server:classes :esb-server:jar :esb-server:assemble :plugins:compilejava up-to-date :plugins:compilescala up-to-date :plugins:processresources up-to-date :plugins:classes up-to-date :plugins:jar :plugins:assemble :raas-transform:assemble :saxonee-helper:assemble :scala-common:compilejava up-to-date :scala-common:compilescala /users/iain.hull/code/trunk/ccdev/scala-common/src/com/workday/esb/assembly/audit/treeaudit.scala:138: method first in trait iterablelike deprecated: use `head' instead     override def getlast():option[auditnode] = if (children.isempty) none else children.first.getlast                                                                                         ^ 1 warning found :scala-common:processresources up-to-date :scala-common:classess :scala-common:jar :scala-common:assemble :plugins:hibernatepersistence:compilejava note: input files use or override deprecated api. note: recompile -xlint:deprecation details. note: input files use unchecked or unsafe operations. note: recompile -xlint:unchecked details. :plugins:hibernatepersistence:compilescala note: input files use or override deprecated api. note: recompile -xlint:deprecation details. note: input files use unchecked or unsafe operations. note: recompile -xlint:unchecked details. :plugins:hibernatepersistence:processresources :plugins:hibernatepersistence:classes :plugins:hibernatepersistence:jar :plugins:hibernatepersistence:assemble 

i know 2 apply plugin lines @ top of root build.gradle causing behaviour. if apply correct plugin each subproject cannot refactor common configuration root build.gradle. approach use scala plugin everything, best way?

can use java plugin compile java projects , scala plugin compile scala projects, , still refactor common build configuration across projects root build.gradle? best way support multiple languages in gradle?

how this:

configure(subprojects.findall {project -> file('src/main/java').exists() }) { apply plugin: 'java' }

configure(subprojects.findall {project -> file('src/main/scala').exists() }) { apply plugin: 'scala' }

since src directory 'src', other discriminator mechanism inside closures needed


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -