From e99be615ce7c2c2b5c3ee5e3f8941c41c1e7a944 Mon Sep 17 00:00:00 2001 From: Kamil Doległo Date: Fri, 31 Jan 2020 00:37:29 +0100 Subject: Bump Gradle version, migrate to Kotlin DSL, refactor publishing --- buildSrc/build.gradle | 10 --- buildSrc/build.gradle.kts | 14 +++++ .../org/jetbrains/CorrectShadowPublishing.groovy | 40 ------------ .../org/jetbrains/DependenciesVersionGetter.groovy | 14 ----- .../org/jetbrains/PluginXmlTransformer.groovy | 71 ---------------------- .../main/kotlin/org/jetbrains/BintrayPublishing.kt | 29 +++++++++ .../kotlin/org/jetbrains/DistMavenPublishing.kt | 28 +++++++++ .../src/main/kotlin/org/jetbrains/DokkaVersion.kt | 19 ++++++ 8 files changed, 90 insertions(+), 135 deletions(-) delete mode 100644 buildSrc/build.gradle create mode 100644 buildSrc/build.gradle.kts delete mode 100644 buildSrc/src/main/groovy/org/jetbrains/CorrectShadowPublishing.groovy delete mode 100644 buildSrc/src/main/groovy/org/jetbrains/DependenciesVersionGetter.groovy delete mode 100644 buildSrc/src/main/groovy/org/jetbrains/PluginXmlTransformer.groovy create mode 100644 buildSrc/src/main/kotlin/org/jetbrains/BintrayPublishing.kt create mode 100644 buildSrc/src/main/kotlin/org/jetbrains/DistMavenPublishing.kt create mode 100644 buildSrc/src/main/kotlin/org/jetbrains/DokkaVersion.kt (limited to 'buildSrc') diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle deleted file mode 100644 index b62b4150..00000000 --- a/buildSrc/build.gradle +++ /dev/null @@ -1,10 +0,0 @@ -apply plugin: 'groovy' -repositories { - mavenCentral() - jcenter() - maven { url "https://dl.bintray.com/kotlin/kotlin-eap" } - maven { url "https://dl.bintray.com/kotlin/kotlin-dev" } -} -dependencies { - compile 'com.github.jengelman.gradle.plugins:shadow:2.0.4' -} diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts new file mode 100644 index 00000000..aeec9540 --- /dev/null +++ b/buildSrc/build.gradle.kts @@ -0,0 +1,14 @@ +plugins { + `kotlin-dsl` + groovy +} + +repositories { + mavenCentral() + jcenter() +} + +dependencies { + implementation("com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4") + implementation("com.github.jengelman.gradle.plugins:shadow:2.0.4") +} diff --git a/buildSrc/src/main/groovy/org/jetbrains/CorrectShadowPublishing.groovy b/buildSrc/src/main/groovy/org/jetbrains/CorrectShadowPublishing.groovy deleted file mode 100644 index 62cc3d3c..00000000 --- a/buildSrc/src/main/groovy/org/jetbrains/CorrectShadowPublishing.groovy +++ /dev/null @@ -1,40 +0,0 @@ -package org.jetbrains - -import org.gradle.api.Project -import org.gradle.api.artifacts.ModuleVersionIdentifier -import org.gradle.api.artifacts.ProjectDependency -import org.gradle.api.artifacts.SelfResolvingDependency -import org.gradle.api.internal.artifacts.ivyservice.projectmodule.ProjectDependencyPublicationResolver -import org.gradle.api.publish.maven.MavenPom -import org.gradle.api.publish.maven.MavenPublication - -//https://github.com/johnrengelman/shadow/issues/334 -static void configure(MavenPublication publication, Project project) { - publication.artifact(project.tasks.shadowJar) - - - publication.pom { MavenPom pom -> - pom.withXml { xml -> - def dependenciesNode = xml.asNode().appendNode('dependencies') - - project.configurations.shadow.allDependencies.each { - if (it instanceof ProjectDependency) { - final ProjectDependencyPublicationResolver projectDependencyResolver = project.gradle.services.get(ProjectDependencyPublicationResolver) - final ModuleVersionIdentifier identifier = projectDependencyResolver.resolve(ModuleVersionIdentifier, it) - addDependency(dependenciesNode, identifier) - } else if (!(it instanceof SelfResolvingDependency)) { - addDependency(dependenciesNode, it) - } - - } - } - } -} - -private static void addDependency(Node dependenciesNode, dep) { - def dependencyNode = dependenciesNode.appendNode('dependency') - dependencyNode.appendNode('groupId', dep.group) - dependencyNode.appendNode('artifactId', dep.name) - dependencyNode.appendNode('version', dep.version) - dependencyNode.appendNode('scope', 'compile') -} diff --git a/buildSrc/src/main/groovy/org/jetbrains/DependenciesVersionGetter.groovy b/buildSrc/src/main/groovy/org/jetbrains/DependenciesVersionGetter.groovy deleted file mode 100644 index 194f11af..00000000 --- a/buildSrc/src/main/groovy/org/jetbrains/DependenciesVersionGetter.groovy +++ /dev/null @@ -1,14 +0,0 @@ -package org.jetbrains - -import org.gradle.api.Project - -class DependenciesVersionGetter { - static Properties getVersions(Project project, String artifactVersionSelector) { - def dep = project.dependencies.create(group: 'teamcity', name: 'dependencies', version: artifactVersionSelector, ext: 'properties') - def file = project.configurations.detachedConfiguration(dep).resolve().first() - - def prop = new Properties() - prop.load(new FileReader(file)) - return prop - } -} diff --git a/buildSrc/src/main/groovy/org/jetbrains/PluginXmlTransformer.groovy b/buildSrc/src/main/groovy/org/jetbrains/PluginXmlTransformer.groovy deleted file mode 100644 index e711388f..00000000 --- a/buildSrc/src/main/groovy/org/jetbrains/PluginXmlTransformer.groovy +++ /dev/null @@ -1,71 +0,0 @@ -package org.jetbrains - -import com.github.jengelman.gradle.plugins.shadow.relocation.RelocateClassContext -import com.github.jengelman.gradle.plugins.shadow.relocation.Relocator -import com.github.jengelman.gradle.plugins.shadow.transformers.Transformer -import com.github.jengelman.gradle.plugins.shadow.transformers.TransformerContext -import groovy.xml.XmlUtil -import org.gradle.api.file.FileTreeElement -import shadow.org.apache.tools.zip.ZipEntry -import shadow.org.apache.tools.zip.ZipOutputStream - -public class PluginXmlTransformer implements Transformer { - private Map transformedPluginXmlFiles = new HashMap<>(); - - @Override - boolean canTransformResource(FileTreeElement fileTreeElement) { - return fileTreeElement.relativePath.segments.contains("META-INF") && fileTreeElement.name.endsWith(".xml") - } - - @Override - void transform(TransformerContext context) { - def path = context.path - def inputStream = context.is - System.out.println(path) - Node node = new XmlParser().parse(inputStream) - relocateXml(node, context) - transformedPluginXmlFiles.put(path, node) - } - - @Override - boolean hasTransformedResource() { - return !transformedPluginXmlFiles.isEmpty() - } - - @Override - void modifyOutputStream(ZipOutputStream zipOutputStream) { - for (Map.Entry entry : transformedPluginXmlFiles.entrySet()) { - zipOutputStream.putNextEntry(new ZipEntry(entry.key)) - XmlUtil.serialize(entry.value, zipOutputStream) - } - } - - private static void relocateXml(Node node, TransformerContext context) { - Map attributes = node.attributes() - RelocateClassContext relocateClassContext = new RelocateClassContext() - relocateClassContext.stats = context.stats - for (Map.Entry entry : attributes.entrySet()) { - relocateClassContext.setClassName((String) entry.getValue()) - entry.setValue(relocateClassName(relocateClassContext, context)) - } - List localText = node.localText() - if (localText.size() == 1) { - relocateClassContext.setClassName(localText[0]) - node.setValue(relocateClassName(relocateClassContext, context)) - } - node.children().each { - if (it instanceof Node) { - relocateXml((Node) it, context) - } - } - } - - private static String relocateClassName(RelocateClassContext relocateContext, TransformerContext context) { - for (Relocator relocator : context.relocators) { - if (relocator.canRelocateClass(relocateContext)) { - return relocator.relocateClass(relocateContext) - } - } - return relocateContext.className - } -} \ 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 new file mode 100644 index 00000000..19e032a8 --- /dev/null +++ b/buildSrc/src/main/kotlin/org/jetbrains/BintrayPublishing.kt @@ -0,0 +1,29 @@ +package org.jetbrains + +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) { + val dokka_version: String by this + val dokka_publication_channel: String by this + extensions.configure("bintray") { + user = System.getenv("BINTRAY_USER") + key = System.getenv("BINTRAY_KEY") + + pkg = PackageConfig().apply { + repo = dokka_publication_channel + name = "dokka" + userOrg = "kotlin" + desc = "Dokka, the Kotlin documentation tool" + vcsUrl = "https://github.com/kotlin/dokka.git" + setLicenses("Apache-2.0") + version = VersionConfig().apply { + name = dokka_version + } + } + setPublications(*publications.toTypedArray()) + } +} \ 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 new file mode 100644 index 00000000..ec536bd7 --- /dev/null +++ b/buildSrc/src/main/kotlin/org/jetbrains/DistMavenPublishing.kt @@ -0,0 +1,28 @@ +package org.jetbrains + +import org.gradle.api.Project +import org.gradle.api.artifacts.repositories.MavenArtifactRepository +import org.gradle.api.publish.PublishingExtension +import org.gradle.api.publish.maven.tasks.PublishToMavenRepository + +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 + } + } + } + } + tasks.register("publishToDistMaven") { + group = "publishing" + description = "Publishes all Maven publications to Maven repository 'distMaven'" + dependsOn(tasks.withType(PublishToMavenRepository::class.java).matching { + it.repository == distMaven + }) + } +} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/org/jetbrains/DokkaVersion.kt b/buildSrc/src/main/kotlin/org/jetbrains/DokkaVersion.kt new file mode 100644 index 00000000..5bd35415 --- /dev/null +++ b/buildSrc/src/main/kotlin/org/jetbrains/DokkaVersion.kt @@ -0,0 +1,19 @@ +package org.jetbrains + +import org.gradle.api.Project +import org.gradle.kotlin.dsl.extra +import org.gradle.kotlin.dsl.provideDelegate + +fun Project.configureDokkaVersion(): String { + var dokka_version: String? by this.extra + if (dokka_version == null) { + val buildNumber = System.getenv("BUILD_NUMBER") + val dokka_version_base: String by this + dokka_version = dokka_version_base + if (buildNumber == null || System.getenv("FORCE_SNAPSHOT") != null) { + "-SNAPSHOT" + } else { + "-$buildNumber" + } + } + return dokka_version!! +} \ No newline at end of file -- cgit From 79ec42607f3bc090ef40547a01aabcd1cd55886e Mon Sep 17 00:00:00 2001 From: Kamil Doległo Date: Fri, 31 Jan 2020 14:04:42 +0100 Subject: Minor fixes, rewritten CrossPlatformExec.kt --- build.gradle.kts | 13 ++-- buildSrc/build.gradle.kts | 1 - .../groovy/org/jetbrains/CrossPlatformExec.groovy | 84 ---------------------- .../main/kotlin/org/jetbrains/BintrayPublishing.kt | 6 +- .../main/kotlin/org/jetbrains/CrossPlatformExec.kt | 67 +++++++++++++++++ .../kotlin/org/jetbrains/DistMavenPublishing.kt | 10 ++- gradle.properties | 11 +-- .../gradle-integration-tests/build.gradle.kts | 36 ++++------ runners/maven-plugin/build.gradle.kts | 30 ++++---- 9 files changed, 108 insertions(+), 150 deletions(-) delete mode 100644 buildSrc/src/main/groovy/org/jetbrains/CrossPlatformExec.groovy create mode 100644 buildSrc/src/main/kotlin/org/jetbrains/CrossPlatformExec.kt (limited to 'buildSrc') 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 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) { +fun Project.configureBintrayPublication(vararg publications: String) { val dokka_version: String by this val dokka_publication_channel: String by this extensions.configure("bintray") { @@ -24,6 +22,6 @@ fun Project.configureBintrayPublication(publications: List) { 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::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 = 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("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") + line.replace("", "$mavenVersion") } filter { line -> line.replace("dokka_version", "$dokka_version") } filter { line -> - line.replace("maven-plugin-plugin", "$maven_plugin_tools_version") + line.replace("maven-plugin-plugin", "$mavenPluginToolsVersion") } } } @@ -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") -- cgit From ec8e0aa7dbdc74c381dfe9c012711a895ccac6d4 Mon Sep 17 00:00:00 2001 From: Kamil Doległo Date: Fri, 31 Jan 2020 15:21:29 +0100 Subject: Fix CrossPlatformExec.kt --- buildSrc/src/main/kotlin/org/jetbrains/CrossPlatformExec.kt | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'buildSrc') diff --git a/buildSrc/src/main/kotlin/org/jetbrains/CrossPlatformExec.kt b/buildSrc/src/main/kotlin/org/jetbrains/CrossPlatformExec.kt index feb32cac..a68329d8 100644 --- a/buildSrc/src/main/kotlin/org/jetbrains/CrossPlatformExec.kt +++ b/buildSrc/src/main/kotlin/org/jetbrains/CrossPlatformExec.kt @@ -20,16 +20,12 @@ open class CrossPlatformExec : AbstractExecTask(CrossPlatform commandLine[0] = findCommand(commandLine[0]) } - if (isWindows) { - if (commandLine.isNotEmpty() && commandLine[0].isNotBlank()) { - commandLine - } - commandLine.add(0, "/c") - commandLine.add(0, "cmd") + if (isWindows && commandLine.isNotEmpty() && commandLine[0].isNotBlank()) { + this.commandLine = listOf("cmd", "/c") + commandLine + } else { + this.commandLine = commandLine } - this.commandLine = commandLine - super.exec() } -- cgit From acc2670f6d641880325bb9826a202486a9410c24 Mon Sep 17 00:00:00 2001 From: Kamil Doległo Date: Thu, 16 Apr 2020 16:31:50 +0200 Subject: Fix a bug in CrossPlatformExec.kt that prevented Windows from running mvn --- buildSrc/src/main/kotlin/org/jetbrains/CrossPlatformExec.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'buildSrc') diff --git a/buildSrc/src/main/kotlin/org/jetbrains/CrossPlatformExec.kt b/buildSrc/src/main/kotlin/org/jetbrains/CrossPlatformExec.kt index a68329d8..e02bdd61 100644 --- a/buildSrc/src/main/kotlin/org/jetbrains/CrossPlatformExec.kt +++ b/buildSrc/src/main/kotlin/org/jetbrains/CrossPlatformExec.kt @@ -35,7 +35,7 @@ open class CrossPlatformExec : AbstractExecTask(CrossPlatform return extensions.map { extension -> resolveCommandFromFile(Paths.get("$command$extension")) - }.firstOrNull() ?: command + }.firstOrNull { it.isNotBlank() } ?: command } private fun resolveCommandFromFile(commandFile: Path) = -- cgit From 012190fbfd049f56637b1039f4ae1f69becea881 Mon Sep 17 00:00:00 2001 From: "sebastian.sellmair" Date: Wed, 1 Jul 2020 17:38:49 +0200 Subject: Gradle integration tests: Use dokka_it_kotlin_version over kotlin_version --- .../src/main/kotlin/org/jetbrains/DokkaVersion.kt | 20 ++++++++++++-------- .../testData/androidApp/app/build.gradle | 2 +- .../gradle/projects/it-basic/build.gradle.kts | 4 +--- .../gradle/projects/it-basic/gradle.properties | 1 + .../gradle/projects/it-basic/settings.gradle.kts | 4 ++-- .../dokka/it/gradle/AbstractGradleIntegrationTest.kt | 6 +++++- 6 files changed, 22 insertions(+), 15 deletions(-) create mode 100644 integration-tests/gradle/projects/it-basic/gradle.properties (limited to 'buildSrc') diff --git a/buildSrc/src/main/kotlin/org/jetbrains/DokkaVersion.kt b/buildSrc/src/main/kotlin/org/jetbrains/DokkaVersion.kt index 5bd35415..d5fd3e78 100644 --- a/buildSrc/src/main/kotlin/org/jetbrains/DokkaVersion.kt +++ b/buildSrc/src/main/kotlin/org/jetbrains/DokkaVersion.kt @@ -7,13 +7,17 @@ import org.gradle.kotlin.dsl.provideDelegate fun Project.configureDokkaVersion(): String { var dokka_version: String? by this.extra if (dokka_version == null) { - val buildNumber = System.getenv("BUILD_NUMBER") val dokka_version_base: String by this - dokka_version = dokka_version_base + if (buildNumber == null || System.getenv("FORCE_SNAPSHOT") != null) { - "-SNAPSHOT" - } else { - "-$buildNumber" - } + dokka_version = dokkaVersionFromBase(dokka_version_base) } - return dokka_version!! -} \ No newline at end of file + return checkNotNull(dokka_version) +} + +private fun dokkaVersionFromBase(baseVersion: String): String { + val buildNumber = System.getenv("BUILD_NUMBER") + val forceSnapshot = System.getenv("FORCE_SNAPSHOT") != null + if (forceSnapshot || buildNumber == null) { + return "$baseVersion-SNAPSHOT" + } + return "$baseVersion-$buildNumber" +} diff --git a/integration-tests/gradle-integration-tests/testData/androidApp/app/build.gradle b/integration-tests/gradle-integration-tests/testData/androidApp/app/build.gradle index 2420107c..0092b76c 100644 --- a/integration-tests/gradle-integration-tests/testData/androidApp/app/build.gradle +++ b/integration-tests/gradle-integration-tests/testData/androidApp/app/build.gradle @@ -42,4 +42,4 @@ android { dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib:$test_kotlin_version" dokkaRuntime files(dokka_fatjar) -} \ No newline at end of file +} diff --git a/integration-tests/gradle/projects/it-basic/build.gradle.kts b/integration-tests/gradle/projects/it-basic/build.gradle.kts index 3e451fd3..80c2bbea 100644 --- a/integration-tests/gradle/projects/it-basic/build.gradle.kts +++ b/integration-tests/gradle/projects/it-basic/build.gradle.kts @@ -1,5 +1,3 @@ -import org.jetbrains.dokka.gradle.dokka - plugins { kotlin("jvm") id("org.jetbrains.dokka") @@ -18,5 +16,5 @@ dependencies { afterEvaluate { logger.quiet("Gradle version: ${gradle.gradleVersion}") - logger.quiet("Kotlin version: ${findProperty("kotlin_version")}") + logger.quiet("Kotlin version: ${properties["dokka_it_kotlin_version"]}") } diff --git a/integration-tests/gradle/projects/it-basic/gradle.properties b/integration-tests/gradle/projects/it-basic/gradle.properties new file mode 100644 index 00000000..7ebac3ad --- /dev/null +++ b/integration-tests/gradle/projects/it-basic/gradle.properties @@ -0,0 +1 @@ +dokka_it_kotlin_version=1.3.72 diff --git a/integration-tests/gradle/projects/it-basic/settings.gradle.kts b/integration-tests/gradle/projects/it-basic/settings.gradle.kts index 9bfd026f..10447365 100644 --- a/integration-tests/gradle/projects/it-basic/settings.gradle.kts +++ b/integration-tests/gradle/projects/it-basic/settings.gradle.kts @@ -1,11 +1,11 @@ @file:Suppress("LocalVariableName", "UnstableApiUsage") pluginManagement { - val kotlin_version = "1.3.72" + val dokka_it_kotlin_version: String by settings val dokka_version = "0.11.0-SNAPSHOT" plugins { - id("org.jetbrains.kotlin.jvm") version kotlin_version + id("org.jetbrains.kotlin.jvm") version dokka_it_kotlin_version id("org.jetbrains.dokka") version dokka_version } diff --git a/integration-tests/gradle/src/main/kotlin/org/jetbrains/dokka/it/gradle/AbstractGradleIntegrationTest.kt b/integration-tests/gradle/src/main/kotlin/org/jetbrains/dokka/it/gradle/AbstractGradleIntegrationTest.kt index 34114c74..d8a9a60f 100644 --- a/integration-tests/gradle/src/main/kotlin/org/jetbrains/dokka/it/gradle/AbstractGradleIntegrationTest.kt +++ b/integration-tests/gradle/src/main/kotlin/org/jetbrains/dokka/it/gradle/AbstractGradleIntegrationTest.kt @@ -23,7 +23,11 @@ abstract class AbstractGradleIntegrationTest { .withProjectDir(projectDir) .withGradleVersion(buildVersions.gradleVersion) .forwardOutput() - .withArguments("-Pkotlin_version=${buildVersions.kotlinVersion}", *arguments) + .withArguments( + "-Pkotlin_version=${buildVersions.kotlinVersion}", + "-Pdokka_it_kotlin_version=${buildVersions.kotlinVersion}", + * arguments + ) .withDebug(true) } -- cgit From a573641a70a626983c1d63965e377ea0be274f41 Mon Sep 17 00:00:00 2001 From: "sebastian.sellmair" Date: Thu, 2 Jul 2020 14:18:51 +0200 Subject: Implement AndroidGradleIntegrationTest --- .github/workflows/gradle-build.pr.yml | 16 -- .github/workflows/gradle-integration-test.pr.yml | 13 ++ .github/workflows/gradle-test.pr.yml | 16 ++ .idea/jarRepositories.xml | 5 + .run/it-android-0_dokka.run.xml | 24 +++ .../src/main/kotlin/org/jetbrains/projectUtils.kt | 16 ++ integration-tests/build.gradle.kts | 30 ++++ integration-tests/gradle/build.gradle.kts | 19 ++- .../gradle/projects/it-android-0/build.gradle.kts | 19 +++ .../gradle/projects/it-android-0/gradle.properties | 2 + .../it-android-0/gradle/wrapper/gradle-wrapper.jar | Bin 0 -> 58695 bytes .../gradle/wrapper/gradle-wrapper.properties | 5 + .../gradle/projects/it-android-0/gradlew | 183 +++++++++++++++++++++ .../gradle/projects/it-android-0/gradlew.bat | 100 +++++++++++ .../projects/it-android-0/settings.gradle.kts | 5 + .../it-android-0/src/main/AndroidManifest.xml | 1 + .../main/java/it/android/AndroidSpecificClass.kt | 16 ++ .../gradle/projects/template.root.gradle.kts | 4 + .../gradle/projects/template.settings.gradle.kts | 11 ++ .../it/gradle/Android0GradleIntegrationTest.kt | 69 ++++++++ .../dokka/it/gradle/BasicGradleIntegrationTest.kt | 71 ++++++++ .../gradle/Multiplatform0GradleIntegrationTest.kt | 43 +++++ ...AbstractDefaultVersionsGradleIntegrationTest.kt | 84 ---------- .../it/gradle/AbstractGradleIntegrationTest.kt | 30 ++-- .../org/jetbrains/dokka/it/gradle/BuildVersions.kt | 38 ++++- .../kotlin/org/jetbrains/dokka/it/gradle/utils.kt | 29 ---- .../dokka/it/gradle/BasicGradleIntegrationTest.kt | 62 ------- .../gradle/Multiplatform0GradleIntegrationTest.kt | 41 ----- settings.gradle.kts | 1 + 29 files changed, 702 insertions(+), 251 deletions(-) delete mode 100644 .github/workflows/gradle-build.pr.yml create mode 100644 .github/workflows/gradle-integration-test.pr.yml create mode 100644 .github/workflows/gradle-test.pr.yml create mode 100644 .run/it-android-0_dokka.run.xml create mode 100644 buildSrc/src/main/kotlin/org/jetbrains/projectUtils.kt create mode 100644 integration-tests/gradle/projects/it-android-0/build.gradle.kts create mode 100644 integration-tests/gradle/projects/it-android-0/gradle.properties create mode 100644 integration-tests/gradle/projects/it-android-0/gradle/wrapper/gradle-wrapper.jar create mode 100644 integration-tests/gradle/projects/it-android-0/gradle/wrapper/gradle-wrapper.properties create mode 100755 integration-tests/gradle/projects/it-android-0/gradlew create mode 100644 integration-tests/gradle/projects/it-android-0/gradlew.bat create mode 100644 integration-tests/gradle/projects/it-android-0/settings.gradle.kts create mode 100644 integration-tests/gradle/projects/it-android-0/src/main/AndroidManifest.xml create mode 100644 integration-tests/gradle/projects/it-android-0/src/main/java/it/android/AndroidSpecificClass.kt create mode 100644 integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/Android0GradleIntegrationTest.kt create mode 100644 integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/BasicGradleIntegrationTest.kt create mode 100644 integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/Multiplatform0GradleIntegrationTest.kt delete mode 100644 integration-tests/gradle/src/main/kotlin/org/jetbrains/dokka/it/gradle/AbstractDefaultVersionsGradleIntegrationTest.kt delete mode 100644 integration-tests/gradle/src/main/kotlin/org/jetbrains/dokka/it/gradle/utils.kt delete mode 100644 integration-tests/gradle/src/test/kotlin/org/jetbrains/dokka/it/gradle/BasicGradleIntegrationTest.kt delete mode 100644 integration-tests/gradle/src/test/kotlin/org/jetbrains/dokka/it/gradle/Multiplatform0GradleIntegrationTest.kt (limited to 'buildSrc') diff --git a/.github/workflows/gradle-build.pr.yml b/.github/workflows/gradle-build.pr.yml deleted file mode 100644 index 2723ecf4..00000000 --- a/.github/workflows/gradle-build.pr.yml +++ /dev/null @@ -1,16 +0,0 @@ -name: CI - -on: pull_request - -jobs: - build: - strategy: - matrix: - os: [ubuntu-latest, windows-latest] - runs-on: ${{ matrix.os }} - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-java@v1 - with: - java-version: 11 - - run: ./gradlew clean build --stacktrace \ No newline at end of file diff --git a/.github/workflows/gradle-integration-test.pr.yml b/.github/workflows/gradle-integration-test.pr.yml new file mode 100644 index 00000000..bfc1b9d3 --- /dev/null +++ b/.github/workflows/gradle-integration-test.pr.yml @@ -0,0 +1,13 @@ +name: CI (Integration Test) + +on: pull_request + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-java@v1 + with: + java-version: 11 + - run: ./gradlew clean integrationTest -s diff --git a/.github/workflows/gradle-test.pr.yml b/.github/workflows/gradle-test.pr.yml new file mode 100644 index 00000000..2838d975 --- /dev/null +++ b/.github/workflows/gradle-test.pr.yml @@ -0,0 +1,16 @@ +name: CI (Test) + +on: pull_request + +jobs: + build: + strategy: + matrix: + os: [ubuntu-latest, windows-latest] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-java@v1 + with: + java-version: 11 + - run: ./gradlew clean test --stacktrace diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml index e0b545b3..0c589859 100644 --- a/.idea/jarRepositories.xml +++ b/.idea/jarRepositories.xml @@ -96,5 +96,10 @@