Fixed build for publish
This commit is contained in:
parent
e239a77223
commit
7daeedb9ff
@ -12,7 +12,6 @@ allprojects {
|
|||||||
|
|
||||||
subprojects {
|
subprojects {
|
||||||
if (name.startsWith("dataforge")) {
|
if (name.startsWith("dataforge")) {
|
||||||
apply(plugin = "npm-bintray")
|
apply(plugin = "npm-publish")
|
||||||
apply(plugin = "npm-artifactory")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,33 +0,0 @@
|
|||||||
import groovy.lang.GroovyObject
|
|
||||||
import org.jfrog.gradle.plugin.artifactory.dsl.PublisherConfig
|
|
||||||
import org.jfrog.gradle.plugin.artifactory.dsl.ResolverConfig
|
|
||||||
|
|
||||||
plugins {
|
|
||||||
id("com.jfrog.artifactory")
|
|
||||||
}
|
|
||||||
|
|
||||||
artifactory {
|
|
||||||
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)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
@ -1,104 +0,0 @@
|
|||||||
@file:Suppress("UnstableApiUsage")
|
|
||||||
|
|
||||||
import com.jfrog.bintray.gradle.BintrayExtension.PackageConfig
|
|
||||||
import com.jfrog.bintray.gradle.BintrayExtension.VersionConfig
|
|
||||||
|
|
||||||
// Old bintray.gradle script converted to real Gradle plugin (precompiled script plugin)
|
|
||||||
// It now has own dependencies and support type safe accessors
|
|
||||||
// Syntax is pretty close to what we had in Groovy
|
|
||||||
// (excluding Property.set and bintray dynamic configs)
|
|
||||||
|
|
||||||
plugins {
|
|
||||||
id("com.jfrog.bintray")
|
|
||||||
`maven-publish`
|
|
||||||
}
|
|
||||||
|
|
||||||
val vcs = "https://github.com/mipt-npm/kmath"
|
|
||||||
|
|
||||||
// Configure publishing
|
|
||||||
publishing {
|
|
||||||
repositories {
|
|
||||||
maven("https://bintray.com/mipt-npm/scientifik")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Process each publication we have in this project
|
|
||||||
publications.filterIsInstance<MavenPublication>().forEach { publication ->
|
|
||||||
|
|
||||||
// use type safe pom config GSL insterad of old dynamic
|
|
||||||
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 {
|
|
||||||
// delegates for runtime properties
|
|
||||||
val bintrayUser: String? by project
|
|
||||||
val bintrayApiKey: String? by project
|
|
||||||
user = bintrayUser ?: System.getenv("BINTRAY_USER")
|
|
||||||
key = bintrayApiKey ?: 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(delegateClosureOf<PackageConfig> {
|
|
||||||
userOrg = "mipt-npm"
|
|
||||||
repo = "dataforge"
|
|
||||||
name = project.name
|
|
||||||
issueTrackerUrl = "https://github.com/altavir/dataforge-core/issues"
|
|
||||||
setLicenses("Apache-2.0")
|
|
||||||
vcsUrl = vcs
|
|
||||||
version(delegateClosureOf<VersionConfig> {
|
|
||||||
name = project.version.toString()
|
|
||||||
vcsTag = project.version.toString()
|
|
||||||
released = java.util.Date().toString()
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
tasks {
|
|
||||||
bintrayUpload {
|
|
||||||
dependsOn(publishToMavenLocal)
|
|
||||||
doFirst {
|
|
||||||
setPublications(project.publishing.publications
|
|
||||||
.filterIsInstance<MavenPublication>()
|
|
||||||
.filter { !it.name.contains("-test") && it.name != "kotlinMultiplatform" }
|
|
||||||
.map {
|
|
||||||
println("""Uploading artifact "${it.groupId}:${it.artifactId}:${it.version}" from publication "${it.name}""")
|
|
||||||
it.name //https://github.com/bintray/gradle-bintray-plugin/issues/256
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
val publications = project.publishing.publications.filter { !it.name.contains("-test") }.map {
|
|
||||||
println("Uploading artifact '$it.groupId:$it.artifactId:$it.version' from publication '$it.name'")
|
|
||||||
it.name.toString()
|
|
||||||
}.toTypedArray()
|
|
||||||
|
|
||||||
setPublications(*publications)
|
|
||||||
}
|
|
134
buildSrc/src/main/kotlin/npm-publish.gradle.kts
Normal file
134
buildSrc/src/main/kotlin/npm-publish.gradle.kts
Normal file
@ -0,0 +1,134 @@
|
|||||||
|
@file:Suppress("UnstableApiUsage")
|
||||||
|
|
||||||
|
import com.jfrog.bintray.gradle.tasks.BintrayUploadTask
|
||||||
|
import groovy.lang.GroovyObject
|
||||||
|
import org.gradle.api.publish.maven.internal.artifact.FileBasedMavenArtifact
|
||||||
|
import org.jfrog.gradle.plugin.artifactory.dsl.PublisherConfig
|
||||||
|
import org.jfrog.gradle.plugin.artifactory.dsl.ResolverConfig
|
||||||
|
|
||||||
|
// Old bintray.gradle script converted to real Gradle plugin (precompiled script plugin)
|
||||||
|
// It now has own dependencies and support type safe accessors
|
||||||
|
// Syntax is pretty close to what we had in Groovy
|
||||||
|
// (excluding Property.set and bintray dynamic configs)
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
`maven-publish`
|
||||||
|
id("com.jfrog.bintray")
|
||||||
|
id("com.jfrog.artifactory")
|
||||||
|
}
|
||||||
|
|
||||||
|
val vcs = "https://github.com/altavir/dataforge-core"
|
||||||
|
|
||||||
|
// Configure publishing
|
||||||
|
publishing {
|
||||||
|
repositories {
|
||||||
|
maven("https://bintray.com/mipt-npm/dataforge")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Process each publication we have in this project
|
||||||
|
publications.filterIsInstance<MavenPublication>().forEach { publication ->
|
||||||
|
|
||||||
|
// use type safe pom config GSL insterad of old dynamic
|
||||||
|
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 = findProperty("bintrayUser") as? String ?: System.getenv("BINTRAY_USER")
|
||||||
|
key = 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 = "dataforge"
|
||||||
|
name = project.name
|
||||||
|
issueTrackerUrl = "https://github.com/altavir/dataforge-core/issues"
|
||||||
|
setLicenses("Apache-2.0")
|
||||||
|
vcsUrl = vcs
|
||||||
|
version.apply {
|
||||||
|
name = project.version.toString()
|
||||||
|
vcsTag = project.version.toString()
|
||||||
|
released = java.util.Date().toString()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
afterEvaluate {
|
||||||
|
setPublications(*publishing.publications.names.toTypedArray())
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks {
|
||||||
|
bintrayUpload {
|
||||||
|
dependsOn(publishToMavenLocal)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//workaround for bintray
|
||||||
|
tasks.withType<BintrayUploadTask> {
|
||||||
|
doFirst {
|
||||||
|
publishing.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"
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
artifactory {
|
||||||
|
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