Skip to content

Commit 075f869

Browse files
committed
Gradle version 5.6.1
* Gradle metadata format version 1.0 (stable) * Using Gradle publish task for publishing * Skip publishing to NPM when auth token is not set Fixes #70
1 parent f30ccba commit 075f869

File tree

9 files changed

+66
-76
lines changed

9 files changed

+66
-76
lines changed

atomicfu-gradle-plugin/src/main/kotlin/kotlinx/atomicfu/plugin/gradle/AtomicFUGradlePlugin.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,8 +345,7 @@ fun AtomicFUTransformJsTask.configureJsTask(
345345
verbose = config.verbose
346346
}
347347

348-
fun Jar.setupJarManifest(multiRelease: Boolean, classifier: String = "") {
349-
this.classifier = classifier // todo: why we overwrite jar's classifier?
348+
fun Jar.setupJarManifest(multiRelease: Boolean) {
350349
if (multiRelease) {
351350
manifest.attributes.apply {
352351
put("Multi-Release", "true")

atomicfu-gradle-plugin/src/test/kotlin/kotlinx/atomicfu/plugin/gradle/BaseKotlinGradleTest.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ abstract class BaseKotlinGradleTest {
2121
val projectDir = workingDir.resolve(name).apply { mkdirs() }
2222
originalProjectDir.listFiles().forEach { it.copyRecursively(projectDir.resolve(it.name)) }
2323

24+
// Add an empty setting.gradle
25+
projectDir.resolve("settings.gradle").writeText("// this file is intentionally left empty")
26+
2427
Project(projectDir = projectDir).fn()
2528
}
2629
}

atomicfu-native/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44

55
// this is a kludge so that existing YouTrack config works, todo: remove
66
// Deploy configurations run :atomicfu-native:bintrayUpload
7-
task bintrayUpload(dependsOn: ':atomicfu:bintrayUpload')
7+
task bintrayUpload(dependsOn: ':atomicfu:publish')

atomicfu/build.gradle

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -232,9 +232,5 @@ afterEvaluate {
232232
js.artifactId = 'atomicfu-js'
233233
metadata.artifactId = 'atomicfu-common'
234234
kotlinMultiplatform.artifactId = 'atomicfu-native'
235-
236-
configure([metadata, jvm, js]) { pub ->
237-
pub.moduleDescriptorGenerator = null
238-
}
239235
}
240236
}

build.gradle

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ buildscript {
3737
dependencies {
3838
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
3939
classpath "com.moowork.gradle:gradle-node-plugin:$gradle_node_version"
40-
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:$bintray_version"
4140
}
4241
}
4342

@@ -90,4 +89,4 @@ if (build_snapshot_train) {
9089
}
9190

9291
// main deployment task
93-
task deploy(dependsOn: getTasksByName("bintrayUpload", true) + getTasksByName("publishNpm", true))
92+
task deploy(dependsOn: getTasksByName("publish", true) + getTasksByName("publishNpm", true))

gradle.properties

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ asm_version=5.2
66
slf4j_version=1.8.0-alpha2
77
junit_version=4.12
88

9-
# This is a specially built version from kotlin-native-dependencies repo that supports Gradle 4.10
10-
bintray_version=1.8.4-jetbrains-5
11-
129
maven_version=3.5.3
1310

1411
gradle_node_version=1.2.0

gradle/publish-bintray.gradle

Lines changed: 45 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -6,92 +6,76 @@
66

77
apply plugin: 'maven'
88
apply plugin: 'maven-publish'
9-
apply plugin: 'com.jfrog.bintray'
109

1110
apply from: project.rootProject.file('gradle/maven-central.gradle')
1211

1312
// todo: figure out how we can check it in a generic way
1413
def isMultiplatform = project.name == 'atomicfu'
1514

16-
// ------------- tasks
17-
18-
// workaround for tasks created by native plugin
1915
if (!isMultiplatform) {
16+
// Regular java modules need 'java-library' plugin for proper publication
17+
apply plugin: 'java-library'
18+
19+
// MPP projects pack their sources automtically, java libraries need to explicitly pack them
2020
task sourcesJar(type: Jar) {
21-
classifier = 'sources'
21+
archiveClassifier = 'sources'
2222
from "src/main/kotlin"
2323
}
24-
25-
// empty xxx-javadoc.jar
26-
task javadocJar(type: Jar) {
27-
classifier = 'javadoc'
28-
from "$buildDir/javadoc" // would not exist
29-
}
3024
}
3125

32-
task stubSources(type: Jar) {
33-
classifier = 'sources'
34-
}
35-
36-
task stubJavadoc(type: Jar) {
37-
classifier = 'javadoc'
26+
// empty xxx-javadoc.jar
27+
task javadocJar(type: Jar) {
28+
archiveClassifier = 'javadoc'
3829
}
3930

4031
publishing {
4132
repositories {
42-
maven { url = 'https://kotlin.bintray.com/kotlinx' }
43-
}
44-
publications.all {
45-
pom.withXml(configureMavenCentralMetadata)
46-
}
33+
maven {
34+
def user = 'kotlin'
35+
def repo = 'kotlinx'
36+
def name = 'kotlinx.atomicfu'
37+
url = "https://api.bintray.com/maven/$user/$repo/$name/;publish=0"
4738

39+
credentials {
40+
username = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER')
41+
password = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY')
42+
}
43+
}
44+
}
45+
4846
if (!isMultiplatform) {
47+
// Configure java publications for non-MPP projects
4948
publications {
50-
maven(MavenPublication) {
51-
from components.java
52-
artifact sourcesJar
53-
artifact javadocJar
54-
55-
if (project.name.endsWith("-maven-plugin")) {
56-
pom.packaging = 'maven-plugin'
49+
// plugin configures its own publication pluginMaven
50+
if (project.name == 'atomicfu-gradle-plugin') {
51+
pluginMaven(MavenPublication) {
52+
artifact sourcesJar
5753
}
58-
}
59-
}
60-
} else {
61-
afterEvaluate {
62-
kotlin.targets.forEach { target ->
63-
def targetPublication = publications.findByName(target.name)
64-
if (targetPublication != null) {
65-
targetPublication.artifact stubJavadoc
54+
} else {
55+
maven(MavenPublication) {
56+
from components.java
57+
artifact sourcesJar
58+
59+
if (project.name.endsWith("-maven-plugin")) {
60+
pom.packaging = 'maven-plugin'
61+
}
6662
}
6763
}
6864
}
6965
}
70-
}
7166

72-
bintray {
73-
user = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER')
74-
key = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY')
75-
override = true // for multi-platform Kotlin/Native publishing
76-
pkg {
77-
userOrg = 'kotlin'
78-
repo = 'kotlinx'
79-
name = 'kotlinx.atomicfu'
80-
version {
81-
name = project.version
82-
vcsTag = project.version
83-
released = new Date()
84-
}
85-
}
86-
}
67+
publications.all {
68+
pom.withXml(configureMavenCentralMetadata)
8769

88-
// TODO :kludge this is required for K/N publishing
89-
bintrayUpload.dependsOn publishToMavenLocal
70+
// add empty javadocs (no need for MPP root publication which publishes only pom file)
71+
if (it.name != 'kotlinMultiplatform') {
72+
it.artifact(javadocJar)
73+
}
9074

91-
// This is for easier debugging of bintray uploading problems
92-
bintrayUpload.doFirst {
93-
publications = project.publishing.publications.findAll { !it.name.contains('-test') }.collect {
94-
println("Uploading artifact '$it.groupId:$it.artifactId:$it.version' from publication '$it.name'")
95-
it
75+
// disable metadata everywhere, but in native modules
76+
def type = it.name
77+
if (type == 'maven' || type == 'metadata' || type == 'jvm' || type == 'js' || type == 'pluginMaven') {
78+
moduleDescriptorGenerator = null
79+
}
9680
}
97-
}
81+
}

gradle/publish-npm-js.gradle

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ task preparePublishNpm(type: Copy, dependsOn: [compileKotlinJs]) {
2929
into npmDeployDir
3030
}
3131

32-
task publishNpm(type: NpmTask, dependsOn: [preparePublishNpm]) {
32+
task performPublishNpm(type: NpmTask, dependsOn: [preparePublishNpm]) {
3333
workingDir = npmDeployDir
3434
def deployArgs = ['publish',
3535
"--//registry.npmjs.org/:_authToken=$authToken",
@@ -42,4 +42,17 @@ task publishNpm(type: NpmTask, dependsOn: [preparePublishNpm]) {
4242
args = deployArgs
4343
}
4444
}
45+
46+
if (authToken == "") {
47+
enabled = false // skip npm publishing when token is not set
48+
}
49+
}
50+
51+
task publishNpm(dependsOn: performPublishNpm) {
52+
doFirst {
53+
if (!performPublishNpm.enabled) {
54+
println("NOTE: publishNpm is skipped because 'kotlin.npmjs.auth.token' is not set")
55+
}
56+
}
4557
}
58+
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
#Tue Jul 02 20:11:54 MSK 2019
21
distributionBase=GRADLE_USER_HOME
32
distributionPath=wrapper/dists
43
zipStoreBase=GRADLE_USER_HOME
54
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10-all.zip
5+
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.1-all.zip

0 commit comments

Comments
 (0)