I have multi project build. One project is Java and uses the java plugin, one project is C and uses the c plugin.
The C code loads the JVM into a running executable, and as such the C project is dependent on the Java project. I have been trying to find a way to compile the Java code automatically prior to compiling and linking the C code.
When I have done this kind of thing before using multiple Java projects, I have used something like the following
dependencies {
compile project(':second')
}
however I think this is only defined by the java addin, and therefore fails when I insert this into my C Project.
What would be the best way to ensure the Java code is always compiled and up to date prior to compiling and linking the C code?
Thanks.
as an update, this is my build file to date.
buildscript {
repositories {
maven { url "http://clojars.org/repo" }
mavenCentral()
}
dependencies { classpath "clojuresque:clojuresque:1.7.0" }
}
project(':broker') {
apply plugin: "c"
apply plugin: "cunit"
model {
platforms {
x86 {
architecture "x86"
}
}
repositories {
libs(PrebuiltLibraries) {
cunit {
headers.srcDir "G:/dev/libs/CUnit-2.1-3/headers"
binaries.withType(StaticLibraryBinary) {
staticLibraryFile = file("G:/dev/libs/CUnit-2.1-3/lib/cunitStaticLibrary/vs2013/cunit.lib")
}
}
jvm_1_8_x32 {
headers.srcDirs "G:/ProgX32/java/jdk1.8.0_20-32bit/include", "G:/ProgX32/java/jdk1.8.0_20-32bit/include/win32"
binaries.withType(StaticLibraryBinary) {
staticLibraryFile = file("G:/ProgX32/java/jdk1.8.0_20-32bit/lib/jvm.lib")
}
}
}
}
components {
broker(NativeLibrarySpec) {
targetPlatform "x86"
}
}
}
binaries.withType(CUnitTestSuiteBinarySpec) {
lib library: "cunit", linkage: "static"
}
binaries.all {
lib library: "jvm_1_8_x32", linkage: "static"
cCompiler.define "WIN32_LEAN_AND_MEAN"
cCompiler.define "UNICODE"
cCompiler.define "NDEBUG"
cCompiler.define "EXPORTING"
if (toolChain in VisualCpp) {
cCompiler.args "/EHsc"
cCompiler.args "/Zi"
cCompiler.args "/FS"
linker.args "/DEBUG" }
}
}
project(':trader') {
apply plugin: "clojure"
apply plugin: "java"
sourceSets {
main {
clojure {
srcDir './trader/src/main/clojure/'
}
}
}
repositories {
mavenCentral()
clojarsRepo()
}
clojure.aotCompile = true
sourceCompatibility = 1.8
version = '0.0'
dependencies {
compile 'org.clojure:clojure:1.6.0'
compile 'com.taoensso:timbre:4.1.0'
compile group: 'junit', name: 'junit', version: '4.11'
testCompile group: 'org.hamcrest', name: 'hamcrest-all', version: '1.3'
}
}
I have been unable to so far to get trader to build prior to broker, given that broker is first alphabetically.
adding:
dependencies {
compile project(":trader")
}
into the broker build file fails with
Could not find method compile() for arguments [project ‘:trader’] on org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler_Decorated@1329683.
presumably because the java plugin is not defined in the project, however adding it breaks the broker build, which fails with
Could not find method lib() for arguments [{library=jvm_1_8_x32, linkage=static}] on classes ‘main’.
I have also tried adding
evaluationDependsOn(‘:trader’)
into the broker build, with little success
It seems like it should be an easy thing to do and maybe I am missing something obvious. Thanks in advance.