initial commit
This commit is contained in:
parent
9c8593ed6e
commit
cd9bf6adc2
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
out/
|
||||
build/
|
||||
.idea/
|
||||
.gradle
|
113
build.gradle.kts
Normal file
113
build.gradle.kts
Normal file
@ -0,0 +1,113 @@
|
||||
import java.util.*
|
||||
|
||||
plugins {
|
||||
`kotlin-dsl`
|
||||
`maven-publish`
|
||||
// id("com.gradle.plugin-publish") version "0.10.1"
|
||||
id("com.jfrog.bintray") version "1.8.4"
|
||||
}
|
||||
|
||||
group = "scientifik"
|
||||
version = "0.1.0"
|
||||
|
||||
repositories {
|
||||
gradlePluginPortal()
|
||||
jcenter()
|
||||
}
|
||||
|
||||
val kotlinVersion = "1.3.40"
|
||||
|
||||
// Add plugins used in buildSrc as dependencies, also we should specify version only here
|
||||
dependencies {
|
||||
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
|
||||
implementation("org.jfrog.buildinfo:build-info-extractor-gradle:4.9.6")
|
||||
implementation("com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4")
|
||||
implementation("org.jetbrains.dokka:dokka-gradle-plugin:0.9.18")
|
||||
implementation("com.moowork.gradle:gradle-node-plugin:1.3.1")
|
||||
implementation("org.openjfx:javafx-plugin:0.0.7")
|
||||
}
|
||||
|
||||
gradlePlugin {
|
||||
plugins {
|
||||
create("scientifik-publish") {
|
||||
id = "scientifik.publish"
|
||||
description = "The publication plugin for bintray and artifactory"
|
||||
implementationClass = "scientifik.ScientifikPublishPlugin"
|
||||
}
|
||||
create("scientifik-mpp") {
|
||||
id = "scientifik.mpp"
|
||||
description = "Pre-configured multiplatform project"
|
||||
implementationClass = "scientifik.ScientifikMPPlugin"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
publishing {
|
||||
repositories {
|
||||
maven("https://bintray.com/mipt-npm/scientifik")
|
||||
}
|
||||
|
||||
val vcs = "https://github.com/mipt-npm/scientifik-gradle-tools"
|
||||
|
||||
// Process each publication we have in this project
|
||||
publications.filterIsInstance<MavenPublication>().forEach { publication ->
|
||||
|
||||
@Suppress("UnstableApiUsage")
|
||||
publication.pom {
|
||||
name.set(project.name)
|
||||
description.set(project.description)
|
||||
url.set(vcs)
|
||||
|
||||
licenses {
|
||||
license {
|
||||
name.set("The Apache Software License, Version 2.0")
|
||||
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
|
||||
distribution.set("repo")
|
||||
}
|
||||
}
|
||||
developers {
|
||||
developer {
|
||||
id.set("MIPT-NPM")
|
||||
name.set("MIPT nuclear physics methods laboratory")
|
||||
organization.set("MIPT")
|
||||
organizationUrl.set("http://npm.mipt.ru")
|
||||
}
|
||||
|
||||
}
|
||||
scm {
|
||||
url.set(vcs)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bintray {
|
||||
user = project.findProperty("bintrayUser") as? String ?: System.getenv("BINTRAY_USER")
|
||||
key = project.findProperty("bintrayApiKey") as? String? ?: System.getenv("BINTRAY_API_KEY")
|
||||
publish = true
|
||||
override = true // for multi-platform Kotlin/Native publishing
|
||||
|
||||
// We have to use delegateClosureOf because bintray supports only dynamic groovy syntax
|
||||
// this is a problem of this plugin
|
||||
pkg.apply {
|
||||
userOrg = "mipt-npm"
|
||||
repo = "scientifik"
|
||||
name = project.name
|
||||
issueTrackerUrl = "$vcs/issues"
|
||||
setLicenses("Apache-2.0")
|
||||
vcsUrl = vcs
|
||||
version.apply {
|
||||
name = project.version.toString()
|
||||
vcsTag = project.version.toString()
|
||||
released = Date().toString()
|
||||
}
|
||||
}
|
||||
|
||||
//workaround bintray bug
|
||||
project.afterEvaluate {
|
||||
setPublications(*project.extensions.findByType<PublishingExtension>()!!.publications.names.toTypedArray())
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
2
settings.gradle
Normal file
2
settings.gradle
Normal file
@ -0,0 +1,2 @@
|
||||
rootProject.name = 'gradle-tools'
|
||||
|
9
src/main/kotlin/Scientifik.kt
Normal file
9
src/main/kotlin/Scientifik.kt
Normal file
@ -0,0 +1,9 @@
|
||||
/**
|
||||
* Build constants
|
||||
*/
|
||||
object Scientifik {
|
||||
val ioVersion = "0.1.10"
|
||||
val coroutinesVersion = "1.2.2"
|
||||
val atomicfuVersion = "0.12.9"
|
||||
val serializationVersion = "0.11.1"
|
||||
}
|
7
src/main/kotlin/scientifik/ScientifikExtension.kt
Normal file
7
src/main/kotlin/scientifik/ScientifikExtension.kt
Normal file
@ -0,0 +1,7 @@
|
||||
package scientifik
|
||||
|
||||
open class ScientifikExtension {
|
||||
var vcs: String? = null
|
||||
var bintrayRepo: String? = null
|
||||
var kdoc: Boolean = true
|
||||
}
|
81
src/main/kotlin/scientifik/ScientifikMPPlugin.kt
Normal file
81
src/main/kotlin/scientifik/ScientifikMPPlugin.kt
Normal file
@ -0,0 +1,81 @@
|
||||
package scientifik
|
||||
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.kotlin.dsl.configure
|
||||
import org.gradle.kotlin.dsl.getValue
|
||||
import org.gradle.kotlin.dsl.getting
|
||||
import org.gradle.kotlin.dsl.invoke
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
||||
|
||||
open class ScientifikMPPlugin : Plugin<Project> {
|
||||
override fun apply(project: Project) {
|
||||
project.plugins.apply("org.jetbrains.kotlin.multiplatform")
|
||||
|
||||
project.configure<KotlinMultiplatformExtension> {
|
||||
jvm {
|
||||
compilations.all {
|
||||
kotlinOptions {
|
||||
jvmTarget = "1.8"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
js {
|
||||
compilations.all {
|
||||
kotlinOptions {
|
||||
sourceMap = true
|
||||
sourceMapEmbedSources = "always"
|
||||
moduleKind = "umd"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets.invoke {
|
||||
val commonMain by getting {
|
||||
dependencies {
|
||||
api(kotlin("stdlib"))
|
||||
}
|
||||
}
|
||||
val commonTest by getting {
|
||||
dependencies {
|
||||
implementation(kotlin("test-common"))
|
||||
implementation(kotlin("test-annotations-common"))
|
||||
}
|
||||
}
|
||||
val jvmMain by getting {
|
||||
dependencies {
|
||||
api(kotlin("stdlib-jdk8"))
|
||||
}
|
||||
}
|
||||
val jvmTest by getting {
|
||||
dependencies {
|
||||
implementation(kotlin("test"))
|
||||
implementation(kotlin("test-junit"))
|
||||
}
|
||||
}
|
||||
val jsMain by getting {
|
||||
dependencies {
|
||||
api(kotlin("stdlib-js"))
|
||||
}
|
||||
}
|
||||
val jsTest by getting {
|
||||
dependencies {
|
||||
implementation(kotlin("test-js"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
targets.all {
|
||||
sourceSets.all {
|
||||
languageSettings.apply{
|
||||
progressiveMode = true
|
||||
enableLanguageFeature("InlineClasses")
|
||||
useExperimentalAnnotation("ExperimentalUnsignedType")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
233
src/main/kotlin/scientifik/ScientifikPublishPlugin.kt
Normal file
233
src/main/kotlin/scientifik/ScientifikPublishPlugin.kt
Normal file
@ -0,0 +1,233 @@
|
||||
package scientifik
|
||||
|
||||
import com.jfrog.bintray.gradle.BintrayExtension
|
||||
import com.jfrog.bintray.gradle.tasks.BintrayUploadTask
|
||||
import groovy.lang.GroovyObject
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.plugins.JavaBasePlugin
|
||||
import org.gradle.api.publish.PublishingExtension
|
||||
import org.gradle.api.publish.maven.MavenPublication
|
||||
import org.gradle.api.publish.maven.internal.artifact.FileBasedMavenArtifact
|
||||
import org.gradle.api.tasks.bundling.Jar
|
||||
import org.gradle.kotlin.dsl.*
|
||||
import org.jetbrains.dokka.gradle.DokkaTask
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
||||
import org.jfrog.gradle.plugin.artifactory.dsl.ArtifactoryPluginConvention
|
||||
import org.jfrog.gradle.plugin.artifactory.dsl.PublisherConfig
|
||||
import org.jfrog.gradle.plugin.artifactory.dsl.ResolverConfig
|
||||
import org.jfrog.gradle.plugin.artifactory.task.ArtifactoryTask
|
||||
|
||||
|
||||
// recursively search up the project chain for configuration
|
||||
private val Project.bintrayRepo: String?
|
||||
get() = extensions.findByType<ScientifikExtension>()?.bintrayRepo
|
||||
?: parent?.bintrayRepo
|
||||
?: (findProperty("bintrayRepo") as? String)
|
||||
|
||||
private val Project.vcs: String?
|
||||
get() = extensions.findByType<ScientifikExtension>()?.vcs
|
||||
?: parent?.vcs
|
||||
?: (findProperty("vcs") as? String)
|
||||
|
||||
open class ScientifikPublishPlugin : Plugin<Project> {
|
||||
|
||||
override fun apply(project: Project) {
|
||||
|
||||
project.plugins.apply("maven-publish")
|
||||
val extension = project.extensions.create<ScientifikExtension>("scientifik")
|
||||
|
||||
val bintrayRepo = project.bintrayRepo
|
||||
val vcs = project.vcs
|
||||
|
||||
if (bintrayRepo == null || vcs == null) {
|
||||
project.logger.warn("[${project.name}] Missing deployment configuration. Skipping publish.")
|
||||
}
|
||||
|
||||
project.configure<PublishingExtension> {
|
||||
repositories {
|
||||
maven("https://bintray.com/mipt-npm/$bintrayRepo")
|
||||
}
|
||||
|
||||
// Process each publication we have in this project
|
||||
publications.filterIsInstance<MavenPublication>().forEach { publication ->
|
||||
|
||||
@Suppress("UnstableApiUsage")
|
||||
publication.pom {
|
||||
name.set(project.name)
|
||||
description.set(project.description)
|
||||
url.set(vcs)
|
||||
|
||||
licenses {
|
||||
license {
|
||||
name.set("The Apache Software License, Version 2.0")
|
||||
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
|
||||
distribution.set("repo")
|
||||
}
|
||||
}
|
||||
developers {
|
||||
developer {
|
||||
id.set("MIPT-NPM")
|
||||
name.set("MIPT nuclear physics methods laboratory")
|
||||
organization.set("MIPT")
|
||||
organizationUrl.set("http://npm.mipt.ru")
|
||||
}
|
||||
|
||||
}
|
||||
scm {
|
||||
url.set(vcs)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (extension.kdoc) {
|
||||
project.plugins.apply("org.jetbrains.dokka")
|
||||
|
||||
project.afterEvaluate {
|
||||
extensions.findByType<KotlinMultiplatformExtension>()?.apply {
|
||||
val dokka by tasks.getting(DokkaTask::class) {
|
||||
outputFormat = "html"
|
||||
outputDirectory = "$buildDir/javadoc"
|
||||
jdkVersion = 8
|
||||
|
||||
kotlinTasks {
|
||||
// dokka fails to retrieve sources from MPP-tasks so we only define the jvm task
|
||||
listOf(tasks.getByPath("compileKotlinJvm"))
|
||||
}
|
||||
sourceRoot {
|
||||
// assuming only single source dir
|
||||
path = sourceSets["commonMain"].kotlin.srcDirs.first().toString()
|
||||
platforms = listOf("Common")
|
||||
}
|
||||
// although the JVM sources are now taken from the task,
|
||||
// we still define the jvm source root to get the JVM marker in the generated html
|
||||
sourceRoot {
|
||||
// assuming only single source dir
|
||||
path = sourceSets["jvmMain"].kotlin.srcDirs.first().toString()
|
||||
platforms = listOf("JVM")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
val kdocJar by tasks.registering(Jar::class) {
|
||||
group = JavaBasePlugin.DOCUMENTATION_GROUP
|
||||
dependsOn(dokka)
|
||||
archiveClassifier.set("javadoc")
|
||||
from("$buildDir/javadoc")
|
||||
}
|
||||
|
||||
configure<PublishingExtension> {
|
||||
|
||||
targets.all {
|
||||
val publication = publications.findByName(name) as MavenPublication
|
||||
|
||||
// Patch publications with fake javadoc
|
||||
publication.artifact(kdocJar.get())
|
||||
}
|
||||
|
||||
tasks.filter { it is ArtifactoryTask || it is BintrayUploadTask }.forEach {
|
||||
it.doFirst {
|
||||
publications.filterIsInstance<MavenPublication>()
|
||||
.forEach { publication ->
|
||||
val moduleFile =
|
||||
buildDir.resolve("publications/${publication.name}/module.json")
|
||||
if (moduleFile.exists()) {
|
||||
publication.artifact(object : FileBasedMavenArtifact(moduleFile) {
|
||||
override fun getDefaultExtension() = "module"
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
extensions.findByType<KotlinJvmProjectExtension>()?.apply {
|
||||
val dokka by tasks.getting(DokkaTask::class) {
|
||||
outputFormat = "html"
|
||||
outputDirectory = "$buildDir/javadoc"
|
||||
jdkVersion = 8
|
||||
}
|
||||
|
||||
val kdocJar by tasks.registering(Jar::class) {
|
||||
group = JavaBasePlugin.DOCUMENTATION_GROUP
|
||||
dependsOn(dokka)
|
||||
archiveClassifier.set("javadoc")
|
||||
from("$buildDir/javadoc")
|
||||
}
|
||||
|
||||
configure<PublishingExtension> {
|
||||
publications.filterIsInstance<MavenPublication>().forEach { publication ->
|
||||
publication.artifact(kdocJar.get())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
project.plugins.apply("com.jfrog.bintray")
|
||||
|
||||
project.configure<BintrayExtension> {
|
||||
user = project.findProperty("bintrayUser") as? String ?: System.getenv("BINTRAY_USER")
|
||||
key = project.findProperty("bintrayApiKey") as? String? ?: System.getenv("BINTRAY_API_KEY")
|
||||
publish = true
|
||||
override = true // for multi-platform Kotlin/Native publishing
|
||||
|
||||
// We have to use delegateClosureOf because bintray supports only dynamic groovy syntax
|
||||
// this is a problem of this plugin
|
||||
pkg.apply {
|
||||
userOrg = "mipt-npm"
|
||||
repo = bintrayRepo
|
||||
name = project.name
|
||||
issueTrackerUrl = "${vcs}/issues"
|
||||
setLicenses("Apache-2.0")
|
||||
vcsUrl = vcs
|
||||
version.apply {
|
||||
name = project.version.toString()
|
||||
vcsTag = project.version.toString()
|
||||
released = java.util.Date().toString()
|
||||
}
|
||||
}
|
||||
|
||||
//workaround bintray bug
|
||||
project.afterEvaluate {
|
||||
setPublications(*project.extensions.findByType<PublishingExtension>()!!.publications.names.toTypedArray())
|
||||
}
|
||||
|
||||
// project.tasks.figetByPath("bintrayUpload") {
|
||||
// dependsOn(publishToMavenLocal)
|
||||
// }
|
||||
}
|
||||
|
||||
project.plugins.apply("com.jfrog.artifactory")
|
||||
|
||||
project.configure<ArtifactoryPluginConvention> {
|
||||
val artifactoryUser: String? by project
|
||||
val artifactoryPassword: String? by project
|
||||
val artifactoryContextUrl = "http://npm.mipt.ru:8081/artifactory"
|
||||
|
||||
setContextUrl(artifactoryContextUrl)//The base Artifactory URL if not overridden by the publisher/resolver
|
||||
publish(delegateClosureOf<PublisherConfig> {
|
||||
repository(delegateClosureOf<GroovyObject> {
|
||||
setProperty("repoKey", "gradle-dev-local")
|
||||
setProperty("username", artifactoryUser)
|
||||
setProperty("password", artifactoryPassword)
|
||||
})
|
||||
|
||||
defaults(delegateClosureOf<GroovyObject> {
|
||||
invokeMethod("publications", arrayOf("jvm", "js", "kotlinMultiplatform", "metadata"))
|
||||
})
|
||||
})
|
||||
resolve(delegateClosureOf<ResolverConfig> {
|
||||
repository(delegateClosureOf<GroovyObject> {
|
||||
setProperty("repoKey", "gradle-dev")
|
||||
setProperty("username", artifactoryUser)
|
||||
setProperty("password", artifactoryPassword)
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user