Skip to content

Commit

Permalink
[build] Improve composite build
Browse files Browse the repository at this point in the history
  • Loading branch information
ilmat192 committed Jan 17, 2018
1 parent ffad728 commit f409287
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 43 deletions.
3 changes: 1 addition & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,7 @@ task distCompiler(type: Copy) {
into('konan/lib')
}

// TODO: Is there another way to specify a path to shared?
from(file('shared/build/libs')) {
from(file("${gradle.includedBuild('shared').projectDir}/build/libs")) {
into('konan/lib')
}

Expand Down
2 changes: 2 additions & 0 deletions buildSrc/plugins/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ dependencies {
compile gradleApi()
compile localGroovy()
compile group: 'com.ullink.slack', name: 'simpleslackapi', version: '0.6.0'
// An artifact from the included build 'shared' cannot be used here due to https://github.com/gradle/gradle/issues/3768
// TODO: Remove this hack when the bug is fixed
compile project(':shared')
}

Expand Down
14 changes: 14 additions & 0 deletions gradle/loadRootProperties.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
if (!project.hasProperty("rootBuildDirectory")) {
throw new GradleException('Please ensure the "rootBuildDirectory" property is defined before applying this script.')
}

ext.distDir = file("$rootBuildDirectory/dist")

def rootProperties = new Properties()
def rootDir = file(rootBuildDirectory).absolutePath
file("$rootDir/gradle.properties").withReader {
rootProperties.load(it)
}
rootProperties.each { k, v ->
ext.set(k, v)
}
2 changes: 1 addition & 1 deletion performance/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ buildscript {
repositories {

maven {
//TODO: this path should be removed!! But how? O_oc
//TODO: this path should be removed!!
url "https://oss.sonatype.org/content/repositories/snapshots"
}
maven {
Expand Down
27 changes: 17 additions & 10 deletions platformLibs/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,12 @@ buildscript {
dependencies {
classpath "org.jetbrains.kotlin:kotlin-native-gradle-plugin"
}
}

String konanHome = distDir.absolutePath
String jvmArgs = project.findProperty("platformLibsJvmArgs") ?: "-Xmx6G"
ext.setProperty("konan.home", konanHome)
ext.setProperty("konan.jvmArgs", jvmArgs)
// TODO: split jvmArgs in gradle plugin

ext.konanHome = distDir.absolutePath
ext.jvmArgs = project.findProperty("platformLibsJvmArgs") ?: "-Xmx6G"
ext.setProperty("konan.home", konanHome)
ext.setProperty("konan.jvmArgs", jvmArgs)
}

//#region Util functions.
private ArrayList<DefFile> targetDefFiles(String target) {
Expand Down Expand Up @@ -59,8 +57,11 @@ private String defFileToInstallTaskName(String target, String name) {

// TODO: Fix the report in performance project
class KlibInstall extends Exec {
@InputFile
public File klib
public File repo

@Input
public String target

@Override
Expand All @@ -80,19 +81,25 @@ class KlibInstall extends Exec {
'-repository', repo.absolutePath
}
}

@OutputDirectory
File getInstallDir() {
def klibName = klib.name.take(klib.name.lastIndexOf('.'))
return project.file("$repo.absolutePath/$klibName")
}


}

//#endregion

println(targetList)

targetList.each { target ->

ArrayList<Task> installTasks = []

targetDefFiles(target).each { df ->
def libName = defFileToLibName(target, df.name)
def installTaskName = defFileToLibName(target, df.name)
def installTaskName = defFileToInstallTaskName(target, df.name)

konan.targets = [target] // TODO: Support custom targets in gradle plugin.
konanArtifacts {
Expand Down
4 changes: 0 additions & 4 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ include ':runtime'
include ':common'
include ':backend.native:tests'
include ':backend.native:debugger-tests'
// TODO: remove
// TODO: Use 'shared' build in buildSrc and all build scripts as a dependency (of a build script too)
//include ':shared'
//include ':tools:kotlin-native-gradle-plugin'
include ':utilities'
include ':performance'
include ':platformLibs'
Expand Down
13 changes: 3 additions & 10 deletions shared/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,10 @@
*/

buildscript {
ext.mainBuildDir = file('../')
ext.rootBuildDirectory = file('../')

def rootProperties = new Properties()
file("$mainBuildDir/gradle.properties").withReader {
rootProperties.load(it)
}
rootProperties.each { k, v ->
ext.set(k, v)
}

apply from: "$mainBuildDir/gradle/kotlinGradlePlugin.gradle"
apply from: "$rootBuildDirectory/gradle/loadRootProperties.gradle"
apply from: "$rootBuildDirectory/gradle/kotlinGradlePlugin.gradle"
}

apply plugin: 'kotlin'
Expand Down
21 changes: 5 additions & 16 deletions tools/kotlin-native-gradle-plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,10 @@
*/

buildscript {
ext {
mainBuildDir = file('../../') // TODO: move mainBuildDir into gradle.properties
distDir = file("$mainBuildDir/dist")
}

// TODO: Make a separate function?
def rootProperties = new Properties()
file("$mainBuildDir/gradle.properties").withReader {
rootProperties.load(it)
}
rootProperties.each { k, v ->
ext.set(k, v)
}
ext.rootBuildDirectory = file('../../')

apply from: "$mainBuildDir/gradle/kotlinGradlePlugin.gradle"
apply from: "$rootBuildDirectory/gradle/loadRootProperties.gradle"
apply from: "$rootBuildDirectory/gradle/kotlinGradlePlugin.gradle"

repositories {
jcenter()
Expand Down Expand Up @@ -79,7 +68,7 @@ task pluginMetadata {
}

dependencies {
compile "org.jetbrains.kotlin:kotlin-native-shared" // TODO: What about version?
compile 'org.jetbrains.kotlin:kotlin-native-shared'
compile "org.jetbrains.kotlin:kotlin-stdlib:$buildKotlinVersion"
compile gradleApi()

Expand Down Expand Up @@ -112,7 +101,7 @@ test {

processResources {
expand('konanVersion': konanVersion)
from(file("$mainBuildDir/utilities/env_blacklist"))
from(file("$rootBuildDirectory/utilities/env_blacklist"))
}

publishing {
Expand Down

0 comments on commit f409287

Please sign in to comment.