aboutsummaryrefslogtreecommitdiff
path: root/buildSrc/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'buildSrc/src/main')
-rw-r--r--buildSrc/src/main/groovy/org/jetbrains/CorrectShadowPublishing.groovy40
-rw-r--r--buildSrc/src/main/groovy/org/jetbrains/DependenciesVersionGetter.groovy14
-rw-r--r--buildSrc/src/main/groovy/org/jetbrains/PluginXmlTransformer.groovy71
-rw-r--r--buildSrc/src/main/kotlin/org/jetbrains/BintrayPublishing.kt29
-rw-r--r--buildSrc/src/main/kotlin/org/jetbrains/DistMavenPublishing.kt28
-rw-r--r--buildSrc/src/main/kotlin/org/jetbrains/DokkaVersion.kt19
6 files changed, 76 insertions, 125 deletions
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<String, Node> 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<String, Node> 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<String> 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<String>) {
+ val dokka_version: String by this
+ val dokka_publication_channel: String by this
+ extensions.configure<BintrayExtension>("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