diff options
-rw-r--r-- | build.gradle.kts | 13 | ||||
-rw-r--r-- | buildSrc/build.gradle.kts | 1 | ||||
-rw-r--r-- | buildSrc/src/main/groovy/org/jetbrains/CrossPlatformExec.groovy | 84 | ||||
-rw-r--r-- | buildSrc/src/main/kotlin/org/jetbrains/BintrayPublishing.kt | 6 | ||||
-rw-r--r-- | buildSrc/src/main/kotlin/org/jetbrains/CrossPlatformExec.kt | 67 | ||||
-rw-r--r-- | buildSrc/src/main/kotlin/org/jetbrains/DistMavenPublishing.kt | 10 | ||||
-rw-r--r-- | gradle.properties | 11 | ||||
-rw-r--r-- | integration-tests/gradle-integration-tests/build.gradle.kts | 36 | ||||
-rw-r--r-- | runners/maven-plugin/build.gradle.kts | 30 |
9 files changed, 108 insertions, 150 deletions
diff --git a/build.gradle.kts b/build.gradle.kts index 5540184a..aab928e7 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,23 +1,22 @@ import org.jetbrains.configureDistMaven import org.jetbrains.configureDokkaVersion +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { kotlin("jvm") apply false id("com.jfrog.bintray") apply false } +val dokka_version: String by project + allprojects { configureDokkaVersion() - val dokka_version: String by this - if (this == rootProject) { - println("Publication version: $dokka_version") - } group = "org.jetbrains.dokka" version = dokka_version val language_version: String by project - tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile::class).all { + tasks.withType(KotlinCompile::class).all { kotlinOptions { freeCompilerArgs += "-Xjsr305=strict" languageVersion = language_version @@ -40,4 +39,6 @@ subprojects { apply { plugin("org.jetbrains.kotlin.jvm") } -}
\ No newline at end of file +} + +println("Publication version: $dokka_version")
\ No newline at end of file diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index aeec9540..7a7b8f6a 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -1,6 +1,5 @@ plugins { `kotlin-dsl` - groovy } repositories { diff --git a/buildSrc/src/main/groovy/org/jetbrains/CrossPlatformExec.groovy b/buildSrc/src/main/groovy/org/jetbrains/CrossPlatformExec.groovy deleted file mode 100644 index d3973a8a..00000000 --- a/buildSrc/src/main/groovy/org/jetbrains/CrossPlatformExec.groovy +++ /dev/null @@ -1,84 +0,0 @@ -package org.jetbrains - -import org.gradle.api.tasks.AbstractExecTask -import org.gradle.api.tasks.TaskAction -import org.gradle.internal.os.OperatingSystem - -import java.nio.file.Files -import java.nio.file.Path -import java.nio.file.Paths - -class CrossPlatformExec extends AbstractExecTask { - private static final def windowsExtensions = ['bat', 'cmd', 'exe']; - private static final def unixExtensions = [null, 'sh']; - - private boolean windows; - - public CrossPlatformExec() { - super(CrossPlatformExec.class); - windows = OperatingSystem.current().windows; - } - - @Override - @TaskAction - protected void exec() { - List<String> commandLine = this.getCommandLine(); - - if (!commandLine.isEmpty()) { - commandLine[0] = findCommand(commandLine[0], windows); - } - - if (windows) { - if (!commandLine.isEmpty() && commandLine[0]) { - commandLine - } - commandLine.add(0, '/c'); - commandLine.add(0, 'cmd'); - } - - this.setCommandLine(commandLine); - - super.exec(); - } - - private static String findCommand(String command, boolean windows) { - command = normalizeCommandPaths(command); - def extensions = windows ? windowsExtensions : unixExtensions; - - return extensions.findResult(command) { extension -> - Path commandFile - if (extension) { - commandFile = Paths.get(command + '.' + extension); - } else { - commandFile = Paths.get(command); - } - - return resolveCommandFromFile(commandFile, windows); - }; - } - - private static String resolveCommandFromFile(Path commandFile, boolean windows) { - if (!Files.isExecutable(commandFile)) { - return null; - } - - return commandFile.toAbsolutePath().normalize(); - } - - private static String normalizeCommandPaths(String command) { - // need to escape backslash so it works with regex - String backslashSeparator = '\\\\'; - - String forwardSlashSeparator = '/'; - - // escape separator if it's a backslash - char backslash = '\\'; - String separator = File.separatorChar == backslash ? backslashSeparator : File.separator - - return command - // first replace all of the backslashes with forward slashes - .replaceAll(backslashSeparator, forwardSlashSeparator) - // then replace all forward slashes with whatever the separator actually is - .replaceAll(forwardSlashSeparator, separator); - } -}
\ No newline at end of file diff --git a/buildSrc/src/main/kotlin/org/jetbrains/BintrayPublishing.kt b/buildSrc/src/main/kotlin/org/jetbrains/BintrayPublishing.kt index 19e032a8..78e4257f 100644 --- a/buildSrc/src/main/kotlin/org/jetbrains/BintrayPublishing.kt +++ b/buildSrc/src/main/kotlin/org/jetbrains/BintrayPublishing.kt @@ -4,9 +4,7 @@ import com.jfrog.bintray.gradle.BintrayExtension import org.gradle.api.Project import org.gradle.kotlin.dsl.provideDelegate -fun Project.configureBintrayPublication(publication: String) = configureBintrayPublication(listOf(publication)) - -fun Project.configureBintrayPublication(publications: List<String>) { +fun Project.configureBintrayPublication(vararg publications: String) { val dokka_version: String by this val dokka_publication_channel: String by this extensions.configure<BintrayExtension>("bintray") { @@ -24,6 +22,6 @@ fun Project.configureBintrayPublication(publications: List<String>) { name = dokka_version } } - setPublications(*publications.toTypedArray()) + setPublications(*publications) } }
\ No newline at end of file diff --git a/buildSrc/src/main/kotlin/org/jetbrains/CrossPlatformExec.kt b/buildSrc/src/main/kotlin/org/jetbrains/CrossPlatformExec.kt new file mode 100644 index 00000000..feb32cac --- /dev/null +++ b/buildSrc/src/main/kotlin/org/jetbrains/CrossPlatformExec.kt @@ -0,0 +1,67 @@ +package org.jetbrains + +import org.gradle.api.tasks.AbstractExecTask +import org.gradle.internal.os.OperatingSystem +import java.io.File +import java.nio.file.Files +import java.nio.file.Path +import java.nio.file.Paths + +open class CrossPlatformExec : AbstractExecTask<CrossPlatformExec>(CrossPlatformExec::class.java) { + private val windowsExtensions = listOf(".bat", ".cmd", ".exe") + private val unixExtensions = listOf("", ".sh") + + private val isWindows = OperatingSystem.current().isWindows + + override fun exec() { + val commandLine: MutableList<String> = this.commandLine + + if (commandLine.isNotEmpty()) { + commandLine[0] = findCommand(commandLine[0]) + } + + if (isWindows) { + if (commandLine.isNotEmpty() && commandLine[0].isNotBlank()) { + commandLine + } + commandLine.add(0, "/c") + commandLine.add(0, "cmd") + } + + this.commandLine = commandLine + + super.exec() + } + + private fun findCommand(command: String): String { + val command = normalizeCommandPaths(command) + val extensions = if (isWindows) windowsExtensions else unixExtensions + + return extensions.map { extension -> + resolveCommandFromFile(Paths.get("$command$extension")) + }.firstOrNull() ?: command + } + + private fun resolveCommandFromFile(commandFile: Path) = + if (!Files.isExecutable(commandFile)) { + "" + } else { + commandFile.toAbsolutePath().normalize().toString() + } + + + private fun normalizeCommandPaths(command: String): String { + // need to escape backslash so it works with regex + val backslashSeparator = "\\" + val forwardSlashSeparator = "/" + + // get the actual separator + val separator = if (File.separatorChar == '\\') backslashSeparator else File.separator + + return command + // first replace all of the backslashes with forward slashes + .replace(backslashSeparator, forwardSlashSeparator) + // then replace all forward slashes with whatever the separator actually is + .replace(forwardSlashSeparator, separator) + } +}
\ No newline at end of file diff --git a/buildSrc/src/main/kotlin/org/jetbrains/DistMavenPublishing.kt b/buildSrc/src/main/kotlin/org/jetbrains/DistMavenPublishing.kt index ec536bd7..175bbd0b 100644 --- a/buildSrc/src/main/kotlin/org/jetbrains/DistMavenPublishing.kt +++ b/buildSrc/src/main/kotlin/org/jetbrains/DistMavenPublishing.kt @@ -9,12 +9,10 @@ fun Project.configureDistMaven() { // TODO: This can probably be written cleaner val repoLocation = uri(file("${rootProject.buildDir}/dist-maven")) var distMaven: MavenArtifactRepository? = null pluginManager.withPlugin("maven-publish") { - this@configureDistMaven.extensions.findByType(PublishingExtension::class.java)?.let { - it.repositories { - distMaven = maven { - name = "distMaven" - url = repoLocation - } + this@configureDistMaven.extensions.findByType(PublishingExtension::class.java)?.repositories { + distMaven = maven { + name = "distMaven" + url = repoLocation } } } diff --git a/gradle.properties b/gradle.properties index 50aa8fd7..96dfefb5 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,14 +7,5 @@ kotlin_plugin_version=1.3.61-release-180 idea_version=192.5728.98 language_version=1.3 -ant_version=1.9.6 - -# Maven plugin dependencies -maven_version=3.5.0 -maven_archiver_version=2.5 -maven_plugin_tools_version=3.5.2 - -# For CI -mvn=mvn - +# Code style kotlin.code.style=official
\ No newline at end of file diff --git a/integration-tests/gradle-integration-tests/build.gradle.kts b/integration-tests/gradle-integration-tests/build.gradle.kts index d8b3cdc4..03dc2641 100644 --- a/integration-tests/gradle-integration-tests/build.gradle.kts +++ b/integration-tests/gradle-integration-tests/build.gradle.kts @@ -1,6 +1,6 @@ -val dokkaPlugin by configurations.creating -val dokkaCore by configurations.creating -val kotlinGradle by configurations.creating +val dokkaPlugin: Configuration by configurations.creating +val dokkaCore: Configuration by configurations.creating +val kotlinGradle: Configuration by configurations.creating repositories { maven(url = "https://kotlin.bintray.com/kotlin-plugin") @@ -8,26 +8,17 @@ repositories { dependencies { val kotlin_version: String by project - testCompileOnly(group = "org.jetbrains.kotlin", name = "kotlin-stdlib", version = kotlin_version) - testImplementation( - group = "org.jetbrains.kotlin", - name = "kotlin-test-junit", - version = kotlin_version - ) - testImplementation(project(":coreDependencies")) + testCompileOnly("org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version") + testImplementation("org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version") + testImplementation("junit:junit:4.13") + testImplementation(gradleTestKit()) + dokkaPlugin(project(path = ":runners:gradle-plugin")) dokkaCore(project(path = ":core", configuration = "shadow")) - kotlinGradle("org.jetbrains.kotlin:kotlin-gradle-plugin") - - testImplementation(group = "junit", name = "junit", version = "4.13") - testImplementation(gradleTestKit()) } - val createClasspathManifest by tasks.registering { - dependsOn(project(":core").getTasksByName("shadowJar", true)) - val outputDir = file("$buildDir/$name") inputs.files(dokkaPlugin + dokkaCore) outputs.dir(outputDir) @@ -40,15 +31,14 @@ val createClasspathManifest by tasks.registering { } } -val testClasses by tasks.getting - -testClasses.dependsOn(project(":core").getTasksByName("shadowJar", true)) -testClasses.dependsOn(createClasspathManifest) - tasks { + testClasses { + dependsOn(createClasspathManifest) + } + test { systemProperty("android.licenses.overwrite", project.findProperty("android.licenses.overwrite") ?: "") inputs.dir(file("testData")) - exclude("*") // TODO: Remove this exclude when tests are migrated +// exclude("*") // TODO: Remove this exclude when tests are migrated } } diff --git a/runners/maven-plugin/build.gradle.kts b/runners/maven-plugin/build.gradle.kts index 2dffd71c..d97e7973 100644 --- a/runners/maven-plugin/build.gradle.kts +++ b/runners/maven-plugin/build.gradle.kts @@ -1,29 +1,28 @@ import org.jetbrains.configureBintrayPublication - +import org.jetbrains.CrossPlatformExec /** * [mavenBin] configuration is used to download Maven Plugin Plugin * for generating plugin-help.xml and plugin.xml files */ val mavenBin: Configuration by configurations.creating -val maven_version: String by project +val mavenVersion = "3.5.0" +val mavenPluginToolsVersion = "3.5.2" dependencies { implementation(project(":core")) - implementation("org.apache.maven:maven-core:$maven_version") - implementation("org.apache.maven:maven-plugin-api:$maven_version") - val maven_plugin_tools_version: String by project - implementation("org.apache.maven.plugin-tools:maven-plugin-annotations:$maven_plugin_tools_version") - val maven_archiver_version: String by project - implementation("org.apache.maven:maven-archiver:$maven_archiver_version") - - mavenBin(group = "org.apache.maven", name = "apache-maven", version = maven_version, classifier = "bin", ext = "zip") + implementation("org.apache.maven:maven-core:$mavenVersion") + implementation("org.apache.maven:maven-plugin-api:$mavenVersion") + implementation("org.apache.maven.plugin-tools:maven-plugin-annotations:$mavenPluginToolsVersion") + implementation("org.apache.maven:maven-archiver:2.5") compileOnly(kotlin("stdlib-jdk8")) + + mavenBin(group = "org.apache.maven", name = "apache-maven", version = mavenVersion, classifier = "bin", ext = "zip") } val mavenBinDir = "$buildDir/maven-bin" val mavenBuildDir = "$buildDir/maven" -val mvn = File(mavenBinDir, "apache-maven-$maven_version/bin/mvn") +val mvn = File(mavenBinDir, "apache-maven-$mavenVersion/bin/mvn") tasks.named<Delete>("clean") { delete(mavenBinDir) @@ -42,7 +41,6 @@ val setupMaven by tasks.registering(Sync::class) { */ val generatePom by tasks.registering(Copy::class) { val dokka_version: String by project - val maven_plugin_tools_version: String by project from("$projectDir/pom.tpl.xml") { rename("(.*).tpl.xml", "$1.xml") @@ -51,13 +49,13 @@ val generatePom by tasks.registering(Copy::class) { eachFile { filter { line -> - line.replace("<maven.version></maven.version>", "<maven.version>$maven_version</maven.version>") + line.replace("<maven.version></maven.version>", "<maven.version>$mavenVersion</maven.version>") } filter { line -> line.replace("<version>dokka_version</version>", "<version>$dokka_version</version>") } filter { line -> - line.replace("<version>maven-plugin-plugin</version>", "<version>$maven_plugin_tools_version</version>") + line.replace("<version>maven-plugin-plugin</version>", "<version>$mavenPluginToolsVersion</version>") } } } @@ -75,13 +73,13 @@ val syncClasses by tasks.registering(Sync::class) { } } -val helpMojo by tasks.registering(org.jetbrains.CrossPlatformExec::class) { +val helpMojo by tasks.registering(CrossPlatformExec::class) { dependsOn(setupMaven, generatePom, syncClasses) workingDir(mavenBuildDir) commandLine(mvn, "-e", "-B", "org.apache.maven.plugins:maven-plugin-plugin:helpmojo") } -val pluginDescriptor by tasks.registering(org.jetbrains.CrossPlatformExec::class) { +val pluginDescriptor by tasks.registering(CrossPlatformExec::class) { dependsOn(setupMaven, generatePom, syncClasses) workingDir(mavenBuildDir) commandLine(mvn, "-e", "-B", "org.apache.maven.plugins:maven-plugin-plugin:descriptor") |