From a2b6c71f73da776401f4d93a109a2e369289dae3 Mon Sep 17 00:00:00 2001 From: Ilya Matveev Date: Thu, 28 Dec 2017 14:46:24 +0700 Subject: [PATCH] [build] Move shared and gradle-plugin into separate gradle builds Platform libs build will be changed by a separate commit --- Interop/StubGenerator/build.gradle | 2 +- backend.native/build.gradle | 4 +-- backend.native/debugger-tests/build.gradle | 2 +- build.gradle | 24 +++++++------- performance/build.gradle | 14 ++++---- performance/gradle.properties | 1 - samples/settings.gradle | 5 ++- settings.gradle | 14 ++++++-- shared/build.gradle | 19 ++++++++++- shared/settings.gradle | 1 + .../kotlin-native-gradle-plugin/build.gradle | 33 ++++++++++++++----- .../settings.gradle | 1 + 12 files changed, 84 insertions(+), 36 deletions(-) delete mode 100644 performance/gradle.properties create mode 100644 shared/settings.gradle create mode 100644 tools/kotlin-native-gradle-plugin/settings.gradle diff --git a/Interop/StubGenerator/build.gradle b/Interop/StubGenerator/build.gradle index 61be955a818..2777a7630a9 100644 --- a/Interop/StubGenerator/build.gradle +++ b/Interop/StubGenerator/build.gradle @@ -27,5 +27,5 @@ dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib:$buildKotlinVersion" compile "org.jetbrains.kotlin:kotlin-compiler:$buildKotlinVersion" compile project(':Interop:Indexer') - compile project(':shared') + compile 'org.jetbrains.kotlin:kotlin-native-shared' } diff --git a/backend.native/build.gradle b/backend.native/build.gradle index e255187d678..58687cac017 100644 --- a/backend.native/build.gradle +++ b/backend.native/build.gradle @@ -147,10 +147,10 @@ dependencies { compilerCompile kotlinCompilerModule compilerCompile kotlinNativeInterop['llvm'].configuration compilerCompile kotlinNativeInterop['hash'].configuration - compilerCompile project(':shared') + compilerCompile 'org.jetbrains.kotlin:kotlin-native-shared' cli_bcCompile "org.jetbrains.kotlin:kotlin-runtime:$buildKotlinVersion" - cli_bcCompile project(':shared') + cli_bcCompile 'org.jetbrains.kotlin:kotlin-native-shared' cli_bcCompile sourceSets.compiler.output bc_frontendCompile kotlinCompilerModule diff --git a/backend.native/debugger-tests/build.gradle b/backend.native/debugger-tests/build.gradle index 3ccb9229a67..4f6acbccbc3 100644 --- a/backend.native/debugger-tests/build.gradle +++ b/backend.native/debugger-tests/build.gradle @@ -4,7 +4,7 @@ apply plugin: 'kotlin' dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib:$buildKotlinVersion" compile project(path: ':backend.native', configuration: 'cli_bc') - compile project(':shared') + compile 'org.jetbrains.kotlin:kotlin-native-shared' compile 'junit:junit:4.12' } diff --git a/build.gradle b/build.gradle index d2184b94bf8..e07e514b18a 100644 --- a/build.gradle +++ b/build.gradle @@ -150,6 +150,12 @@ class PlatformInfo { } } +// TODO: Add a task for gradle plugin uploading +// TODO: And fix release readme: add info about compiler version and about new gradle-plugin uploading task +task sharedJar { + dependsOn gradle.includedBuild('shared').task(':jar') +} + task dist_compiler(dependsOn: "distCompiler") task dist_runtime(dependsOn: "distRuntime") task cross_dist(dependsOn: "crossDist") @@ -159,7 +165,7 @@ task distCompiler(type: Copy) { dependsOn ':backend.native:jar' dependsOn ':utilities:jar' dependsOn ':klib:jar' - dependsOn ':shared:jar' + dependsOn ':sharedJar' destinationDir distDir @@ -215,7 +221,8 @@ task distCompiler(type: Copy) { into('konan/lib') } - from(project(':shared').file('build/libs')) { + // TODO: Is there another way to specify a path to shared? + from(file('shared/build/libs')) { into('konan/lib') } @@ -440,18 +447,9 @@ task uploadBundle { } } -task performance(type: GradleBuild) { +task performance { dependsOn 'dist' - dependsOn ':tools:kotlin-native-gradle-plugin:jar' - - dir = 'performance' - tasks = ['build', 'bench'] - - doFirst { - startParameter.projectProperties = [ - 'konanPluginClasspath' : project(':tools:kotlin-native-gradle-plugin').tasks.getByName('jar').archivePath.canonicalPath, - 'exe_suffix': TargetManager.host.family.exeSuffix] - } + dependsOn ':performance:bench' } task clean { diff --git a/performance/build.gradle b/performance/build.gradle index 86e5e386429..eb4782017d7 100644 --- a/performance/build.gradle +++ b/performance/build.gradle @@ -1,22 +1,19 @@ buildscript { - def rootProperties = new Properties() - rootProperties.load(new FileReader(project.file('../gradle.properties'))) - rootProperties.each {k, v -> ext.set(k, v)} repositories { maven { - //TODO: this path should be removed!! + //TODO: this path should be removed!! But how? O_oc url "https://oss.sonatype.org/content/repositories/snapshots" } maven { - url rootProperties.kotlinCompilerRepo + url kotlinCompilerRepo } mavenCentral() } dependencies { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinGradlePluginVersion" - classpath files(project.file('../tools/kotlin-native-gradle-plugin/build/libs').listFiles().findAll{it.name.endsWith('.jar')}.collect().first().absolutePath) + classpath "org.jetbrains.kotlin:kotlin-native-gradle-plugin:$konanVersion" } } @@ -39,6 +36,9 @@ apply plugin: 'kotlin' apply plugin: 'application' apply plugin: 'konan' +project.setProperty("konan.home", distDir) +checkKonanCompiler.dependsOn ':dist' + konanArtifacts { program('Ring') { enableOptimizations true @@ -57,6 +57,7 @@ dependencies { } task jvmRun(type: JavaExec) { + dependsOn 'build' def output = new ByteArrayOutputStream() classpath sourceSets.main.runtimeClasspath main = "MainKt" @@ -74,6 +75,7 @@ private void dumpReport(String name, ByteArrayOutputStream output) { } task konanRun(type: Exec) { + dependsOn 'build' def output = new ByteArrayOutputStream() commandLine konanArtifacts.Ring.getByTarget('host').artifact.absolutePath, "$ringWarmup", "$iterations" standardOutput = output diff --git a/performance/gradle.properties b/performance/gradle.properties deleted file mode 100644 index 325d0e31851..00000000000 --- a/performance/gradle.properties +++ /dev/null @@ -1 +0,0 @@ -konan.home=../dist \ No newline at end of file diff --git a/samples/settings.gradle b/samples/settings.gradle index 77562f9a5b9..238123439e5 100644 --- a/samples/settings.gradle +++ b/samples/settings.gradle @@ -21,4 +21,7 @@ include ':uikit' include ':win32' include ':videoplayer' include ':workers' -includeBuild '../' +// TODO: set up some rule to remove these strings in bundle +includeBuild('../shared') { dependencySubstitution { substitute module('org.jetbrains.kotlin:kotlin-native-shared') with project(':') } } +includeBuild '../tools/kotlin-native-gradle-plugin' + diff --git a/settings.gradle b/settings.gradle index 144e89a5131..418a2294e9e 100644 --- a/settings.gradle +++ b/settings.gradle @@ -26,6 +26,16 @@ include ':runtime' include ':common' include ':backend.native:tests' include ':backend.native:debugger-tests' -include ':shared' -include ':tools:kotlin-native-gradle-plugin' +// 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' + +includeBuild 'tools/kotlin-native-gradle-plugin' +includeBuild('shared') { + dependencySubstitution { + substitute module('org.jetbrains.kotlin:kotlin-native-shared') with project(':') + } +} diff --git a/shared/build.gradle b/shared/build.gradle index 1913c8a044c..20f05ab4bbb 100644 --- a/shared/build.gradle +++ b/shared/build.gradle @@ -15,11 +15,28 @@ */ buildscript { - apply from: "$rootDir/gradle/kotlinGradlePlugin.gradle" + ext.mainBuildDir = 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 plugin: 'kotlin' +repositories { + mavenCentral() + maven { + url kotlinCompilerRepo + } +} + dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib:$buildKotlinVersion" } diff --git a/shared/settings.gradle b/shared/settings.gradle new file mode 100644 index 00000000000..b63b95eb360 --- /dev/null +++ b/shared/settings.gradle @@ -0,0 +1 @@ +rootProject.name = "shared" \ No newline at end of file diff --git a/tools/kotlin-native-gradle-plugin/build.gradle b/tools/kotlin-native-gradle-plugin/build.gradle index b7a734a66af..da7920146d7 100644 --- a/tools/kotlin-native-gradle-plugin/build.gradle +++ b/tools/kotlin-native-gradle-plugin/build.gradle @@ -20,7 +20,21 @@ */ buildscript { - apply from: "$rootDir/gradle/kotlinGradlePlugin.gradle" + 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) + } + + apply from: "$mainBuildDir/gradle/kotlinGradlePlugin.gradle" repositories { jcenter() @@ -28,6 +42,7 @@ buildscript { dependencies { classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3' + classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.2' } } apply plugin: 'java' @@ -35,12 +50,16 @@ apply plugin: 'kotlin' apply plugin: 'groovy' apply plugin: 'maven-publish' apply plugin: 'com.jfrog.bintray' +apply plugin: 'com.github.johnrengelman.shadow' group = 'org.jetbrains.kotlin' version = konanVersion repositories { mavenCentral() + maven { + url kotlinCompilerRepo + } } task pluginMetadata { @@ -60,10 +79,12 @@ task pluginMetadata { } dependencies { - compile project(':shared') + compile "org.jetbrains.kotlin:kotlin-native-shared" // TODO: What about version? compile "org.jetbrains.kotlin:kotlin-stdlib:$buildKotlinVersion" compile gradleApi() + shadow "org.jetbrains.kotlin:kotlin-native-shared" + testCompile gradleTestKit() testCompile 'junit:junit:4.12' testCompile('org.spockframework:spock-core:1.1-groovy-2.4') { @@ -89,19 +110,15 @@ test { } } -jar { - from (rootProject.findProject(':shared').sourceSets.main.output) -} - processResources { expand('konanVersion': konanVersion) - from(rootProject.project(':utilities').file('env_blacklist')) + from(file("$mainBuildDir/utilities/env_blacklist")) } publishing { publications { gradlePlugin(MavenPublication) { - artifact jar + artifact shadowJar pom.withXml { XmlProvider xml -> def stdlibDep = xml.asNode().appendNode("dependencies").appendNode("dependency") stdlibDep.appendNode("groupId", "org.jetbrains.kotlin") diff --git a/tools/kotlin-native-gradle-plugin/settings.gradle b/tools/kotlin-native-gradle-plugin/settings.gradle new file mode 100644 index 00000000000..9157a1bfcb5 --- /dev/null +++ b/tools/kotlin-native-gradle-plugin/settings.gradle @@ -0,0 +1 @@ +rootProject.name = "kotlin-native-gradle-plugin" \ No newline at end of file