File: build.gradle

package info (click to toggle)
kotlin 1.3.31%2Bds1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 109,908 kB
  • sloc: java: 454,756; xml: 18,599; javascript: 10,452; sh: 513; python: 97; makefile: 69; ansic: 4
file content (159 lines) | stat: -rw-r--r-- 6,564 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
import java.io.File
import proguard.gradle.ProGuardTask
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import org.gradle.api.artifacts.maven.Conf2ScopeMappingContainer
import org.gradle.api.file.DuplicatesStrategy

plugins {
    // HACK: java plugin makes idea import dependencies on this project as source (with empty sources however),
    // this prevents reindexing of kotlin-compiler.jar after build on every change in compiler modules
    id("java")
}

description = "Kotlin Compiler"

// You can run Gradle with "-Pkotlin.build.proguard=true" to enable ProGuard run on kotlin-compiler.jar (on TeamCity, ProGuard always runs)
ext.shrink =findProperty("kotlin.build.proguard")?.toString()?.toBoolean() ?: hasProperty("teamcity")

configurations.create("fatJarContents")

configurations.create("fatJarContentsStripMetadata")
configurations.create("fatJarContentsStripServices")
configurations.create("fatSourcesJarContents")
configurations.create("fatJar")
configurations.create("compilerJar")
configurations.create("runtimeJar")

configurations.create("libraries") {
    extendsFrom(configurations.compile)
}
configurations.create("trove4jJar")

configurations.default.extendsFrom(configurations.runtimeJar)

ext.compilerBaseName = name
ext.outputJar = CommonUtilKt.customFileFrom(buildDir, ["libs", "${compilerBaseName}.jar".toString()])

ext.compilerModules = rootProject.ext.compilerModules

compilerModules.each { evaluationDependsOn(it) }
ext.compiledModulesSources = compilerModules.collect {
    it=SourceSetsKt.customMainSourceSet(project(it)).allSource
}

dependencies {
    compile(DependenciesKt.customKotlinStdlib(project,null))
    compile(project(":kotlin-script-runtime"))
    compile(project(":kotlin-reflect"))
    compile(DependenciesKt.customCommonDep(project,"org.jetbrains.intellij.deps", "trove4j",[]))

    libraries(project(":kotlin-annotations-jvm"))
    libraries(
        files(
            DependenciesKt.customFirstFromJavaHomeThatExists(project,["jre/lib/rt.jar", "../Classes/classes.jar"],new File(project.property("JDK_18") as String)),
            DependenciesKt.customFirstFromJavaHomeThatExists(project,["jre/lib/jsse.jar", "../Classes/jsse.jar"],new File(project.property("JDK_18") as String)),
            DependenciesKt.customToolsJar(project)
        )
    )

    compilerModules.each {
        fatJarContents(project(it)) { setTransitive(false) }
    }

    compiledModulesSources.each {
        fatSourcesJarContents(it)
    }

    trove4jJar(IntellijDependenciesKt.getIntellijDep(project,"intellij")) { IntellijDependenciesKt.customIncludeIntellijCoreJarDependencies(it,project) { it.startsWith("trove4j") } }

    fatJarContents(project(":core:builtins"))
    fatJarContents(DependenciesKt.customCommonDep(project,"javax.inject"))
    fatJarContents(DependenciesKt.customCommonDep(project,"org.jline", "jline",[]))
    fatJarContents(DependenciesKt.customCommonDep(project,"org.fusesource.jansi", "jansi",[]))
    fatJarContents(DependenciesKt.customProtobufFull(project))
    fatJarContents(DependenciesKt.customCommonDep(project,"com.google.code.findbugs", "jsr305",[]))
    fatJarContents(DependenciesKt.customCommonDep(project,"io.javaslang", "javaslang",[]))
    fatJarContents(DependenciesKt.customCommonDep(project,"org.jetbrains.kotlinx", "kotlinx-coroutines-core",[])) { setTransitive(false) }

    fatJarContents(IntellijDependenciesKt.customIntellijCoreDep(project)) { IntellijDependenciesKt.customIncludeJars(it,["intellij-core", "java-compatibility-1.0.1"],null) }
    fatJarContents(IntellijDependenciesKt.getIntellijDep(project,"intellij")) {
        IntellijDependenciesKt.customIncludeIntellijCoreJarDependencies(it,project) {
            !(it.startsWith("jdom") || it.startsWith("log4j") || it.startsWith("trove4j"))
        }
    }
    fatJarContents(IntellijDependenciesKt.getIntellijDep(project,"intellij")) { IntellijDependenciesKt.customIncludeJars(it,["jna-platform", "lz4-1.3.0"],null) }
    fatJarContentsStripServices(IntellijDependenciesKt.getIntellijDep(project,"jps-standalone")) { IntellijDependenciesKt.customIncludeJars(it,["jps-model"],null) }
    fatJarContentsStripMetadata(IntellijDependenciesKt.getIntellijDep(project,"intellij")) { IntellijDependenciesKt.customIncludeJars(it,["oro-2.0.8", "jdom", "log4j"],null ) }
}

//publish()

ArtifactsKt.customNoDefaultJar(project)

task("packCompiler",type:ShadowJar) {
    configurations = [project.configurations.fatJar]
    setDuplicatesStrategy(DuplicatesStrategy.EXCLUDE)
    destinationDir =new File(buildDir, "libs")

    ArtifactsKt.customSetupPublicJar(it,compilerBaseName, "before-proguard")

    from(project.configurations.fatJarContents)

    dependsOn(project.configurations.fatJarContentsStripServices)
    from {
        project.configurations.fatJarContentsStripServices.files.collect {
            zipTree(it).matching { exclude("META-INF/services/**") }
        }
    }
    dependsOn(project.configurations.fatJarContentsStripMetadata)
    from {
        project.configurations.fatJarContentsStripMetadata.files.collect {
            zipTree(it).matching { exclude("META-INF/jb/**", "META-INF/LICENSE") }
        }
    }

    manifest.attributes["Class-Path"] = DependenciesKt.compilerManifestClassPath
    manifest.attributes["Main-Class"] = "org.jetbrains.kotlin.cli.jvm.K2JVMCompiler"
}

task("proguard",type:ProGuardTask) {
    dependsOn(packCompiler)
    configuration("${rootDir}/compiler/compiler.pro".toString())

    def outputJar = CommonUtilKt.customFileFrom(buildDir, ["libs", "${compilerBaseName}-after-proguard.jar".toString()])

    inputs.files(packCompiler.outputs.files.getSingleFile())
    outputs.file(outputJar)

    // TODO: remove after dropping compatibility with ant build
    doFirst {
        System.setProperty("kotlin-compiler-jar-before-shrink", packCompiler.outputs.files.singleFile.canonicalPath)
        System.setProperty("kotlin-compiler-jar", outputJar.canonicalPath)
    }

    libraryjars(filter : "!META-INF/versions/**",project.configurations.libraries)

    printconfiguration("$buildDir/compiler.pro.dump")
}

Task pack;
if(shrink){
	pack=proguard
}else{
	pack=packCompiler
}

ArtifactsKt.customDist(project,null,"${compilerBaseName}.jar".toString(),pack){
    it.from(configurations.trove4jJar)
}

ArtifactsKt.customRuntimeJarArtifactBy(project,pack, pack.outputs.files.singleFile) {
    it.name = compilerBaseName
    it.classifier = ""
}

ArtifactsKt.customSourcesJar(project,"main") {
    it.from(configurations.fatSourcesJarContents)
}

//javadocJar()