Skip to content

Commit

Permalink
[build] Move shared and gradle-plugin into separate gradle builds
Browse files Browse the repository at this point in the history
Platform libs build will be changed by a separate commit
  • Loading branch information
ilmat192 committed Jan 17, 2018
1 parent 0f85696 commit a2b6c71
Show file tree
Hide file tree
Showing 12 changed files with 84 additions and 36 deletions.
2 changes: 1 addition & 1 deletion Interop/StubGenerator/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
4 changes: 2 additions & 2 deletions backend.native/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion backend.native/debugger-tests/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}

Expand Down
24 changes: 11 additions & 13 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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

Expand Down Expand Up @@ -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')
}

Expand Down Expand Up @@ -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 {
Expand Down
14 changes: 8 additions & 6 deletions performance/build.gradle
Original file line number Diff line number Diff line change
@@ -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"
}
}

Expand All @@ -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
Expand All @@ -57,6 +57,7 @@ dependencies {
}

task jvmRun(type: JavaExec) {
dependsOn 'build'
def output = new ByteArrayOutputStream()
classpath sourceSets.main.runtimeClasspath
main = "MainKt"
Expand All @@ -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
Expand Down
1 change: 0 additions & 1 deletion performance/gradle.properties

This file was deleted.

5 changes: 4 additions & 1 deletion samples/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'

14 changes: 12 additions & 2 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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(':')
}
}
19 changes: 18 additions & 1 deletion shared/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
1 change: 1 addition & 0 deletions shared/settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rootProject.name = "shared"
33 changes: 25 additions & 8 deletions tools/kotlin-native-gradle-plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,46 @@
*/

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()
}

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'
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 {
Expand All @@ -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') {
Expand All @@ -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")
Expand Down
1 change: 1 addition & 0 deletions tools/kotlin-native-gradle-plugin/settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rootProject.name = "kotlin-native-gradle-plugin"

0 comments on commit a2b6c71

Please sign in to comment.