Skip to content

Commit ae53ccb

Browse files
author
Artur Artikov
committed
Change publishing to support new plugin DSL
1 parent 23b6d6f commit ae53ccb

File tree

5 files changed

+103
-92
lines changed

5 files changed

+103
-92
lines changed

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 MobileUp
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

build.gradle

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
buildscript {
2+
ext.kotlinVersion = '1.6.21'
3+
4+
repositories {
5+
google()
6+
mavenCentral()
7+
}
8+
9+
dependencies {
10+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
11+
classpath "org.jetbrains.kotlin:kotlin-serialization:1.6.21"
12+
classpath "io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.30.0"
13+
classpath("org.jetbrains.dokka:dokka-gradle-plugin:1.6.21")
14+
}
15+
}
16+
17+
apply plugin: 'kotlin'
18+
apply plugin: 'org.jetbrains.kotlin.plugin.serialization'
19+
apply plugin: 'java-gradle-plugin'
20+
apply plugin: 'io.codearte.nexus-staging'
21+
apply plugin: 'org.jetbrains.dokka'
22+
23+
repositories {
24+
google()
25+
mavenCentral()
26+
}
27+
28+
dependencies {
29+
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion"
30+
implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.3.3"
31+
implementation "com.google.code.gson:gson:2.8.6"
32+
implementation "junit:junit:4.12"
33+
}
34+
35+
group = 'ru.mobileup'
36+
version = '1.0.0'
37+
38+
gradlePlugin {
39+
plugins {
40+
moduleGraph {
41+
id = 'ru.mobileup.module-graph'
42+
implementationClass = 'ru.mobileup.modulegraph.gradle.ModuleGraphPlugin'
43+
}
44+
}
45+
}
46+
47+
apply from: 'publish.gradle'

build.gradle.kts

-30
This file was deleted.

publish.gradle

+34-62
Original file line numberDiff line numberDiff line change
@@ -5,37 +5,26 @@ apply plugin: 'signing'
55
* Publish:
66
* Fill local.properties according to template-for-local.properties
77
* ./gradlew build
8-
* ./gradlew publishReleasePublicationToSonatypeRepository
8+
* ./gradlew publish
99
* ./gradlew closeAndReleaseRepository
1010
*
1111
* More info: https://getstream.io/blog/publishing-libraries-to-mavencentral-2021/
1212
*/
1313

1414
ext {
15-
PUBLISH_GROUP_ID = 'ru.mobileup'
16-
PUBLISH_ARTIFACT_ID = 'module-graph'
17-
PUBLISH_VERSION = '1.0.0'
18-
DESCRIPTION = 'Gradle plugin for generate graph of dependecies for package features'
19-
15+
DESCRIPTION = 'Gradle plugin to generate graph of dependencies for package features'
2016
GITHUB_USER = 'MobileUpLLC'
2117
GITHUB_PROJECT = 'Module-Graph-Gradle-Plugin'
2218
LICENSE_NAME = 'MIT License'
2319
LICENSE_URL = "https://github.com/${GITHUB_USER}/${GITHUB_PROJECT}/blob/master/LICENSE"
24-
2520
DEVELOPER_ID = 'MobileUp'
2621
DEVELOPER_NAME = 'MobileUp'
2722
DEVELOPER_EMAIL = '[email protected]'
2823
}
2924

30-
task androidSourcesJar(type: Jar) {
25+
task sourcesJar(type: Jar) {
3126
archiveClassifier.set('sources')
32-
if (project.plugins.findPlugin("com.android.library")) {
33-
from android.sourceSets.main.java.srcDirs
34-
from android.sourceSets.main.kotlin.srcDirs
35-
} else {
36-
from sourceSets.main.java.srcDirs
37-
from sourceSets.main.kotlin.srcDirs
38-
}
27+
from sourceSets.main.kotlin.srcDirs
3928
}
4029

4130
task javadocJar(type: Jar, dependsOn: dokkaJavadoc) {
@@ -44,13 +33,10 @@ task javadocJar(type: Jar, dependsOn: dokkaJavadoc) {
4433
}
4534

4635
artifacts {
47-
archives androidSourcesJar
36+
archives sourcesJar
4837
archives javadocJar
4938
}
5039

51-
group = PUBLISH_GROUP_ID
52-
version = PUBLISH_VERSION
53-
5440
ext["signing.keyId"] = ''
5541
ext["signing.password"] = ''
5642
ext["signing.secretKeyRingFile"] = ''
@@ -75,53 +61,40 @@ if (secretPropsFile.exists()) {
7561
}
7662

7763
publishing {
78-
publications {
79-
release(MavenPublication) {
80-
groupId PUBLISH_GROUP_ID
81-
artifactId PUBLISH_ARTIFACT_ID
82-
version PUBLISH_VERSION
83-
if (project.plugins.findPlugin("com.android.library")) {
84-
artifact("$buildDir/outputs/aar/${project.getName()}-release.aar")
85-
} else {
86-
artifact("$buildDir/libs/${project.getName()}-${version}.jar")
64+
// afterEvaluate is necessary because java-gradle-plugin
65+
// creates its publications in an afterEvaluate callback
66+
afterEvaluate {
67+
publications {
68+
// Modify publications created by java-gradle-plugin
69+
70+
pluginMaven {
71+
artifact sourcesJar
72+
artifact javadocJar
8773
}
8874

89-
artifact androidSourcesJar
90-
artifact javadocJar
91-
92-
pom {
93-
name = PUBLISH_ARTIFACT_ID
94-
description = DESCRIPTION
95-
url = "https://github.com/${GITHUB_USER}/${GITHUB_PROJECT}"
96-
licenses {
97-
license {
98-
name = LICENSE_NAME
99-
url = LICENSE_URL
100-
}
101-
}
102-
developers {
103-
developer {
104-
id = DEVELOPER_ID
105-
name = DEVELOPER_NAME
106-
email = DEVELOPER_EMAIL
75+
withType(MavenPublication) {
76+
pom {
77+
name = project.name
78+
description = DESCRIPTION
79+
url = "https://github.com/${GITHUB_USER}/${GITHUB_PROJECT}"
80+
licenses {
81+
license {
82+
name = LICENSE_NAME
83+
url = LICENSE_URL
84+
}
10785
}
108-
}
109-
scm {
110-
connection = "scm:git:github.com/${GITHUB_USER}/${GITHUB_PROJECT}.git"
111-
developerConnection = "scm:git:ssh://github.com/${GITHUB_USER}/${GITHUB_PROJECT}.git"
112-
url = "https://github.com/${GITHUB_USER}/${GITHUB_PROJECT}/tree/main"
113-
}
114-
withXml {
115-
def dependenciesNode = asNode().appendNode('dependencies')
116-
117-
project.configurations.implementation.allDependencies.each {
118-
if (it.name != 'unspecified') {
119-
def dependencyNode = dependenciesNode.appendNode('dependency')
120-
dependencyNode.appendNode('groupId', it.group)
121-
dependencyNode.appendNode('artifactId', it.name)
122-
dependencyNode.appendNode('version', it.version)
86+
developers {
87+
developer {
88+
id = DEVELOPER_ID
89+
name = DEVELOPER_NAME
90+
email = DEVELOPER_EMAIL
12391
}
12492
}
93+
scm {
94+
connection = "scm:git:github.com/${GITHUB_USER}/${GITHUB_PROJECT}.git"
95+
developerConnection = "scm:git:ssh://github.com/${GITHUB_USER}/${GITHUB_PROJECT}.git"
96+
url = "https://github.com/${GITHUB_USER}/${GITHUB_PROJECT}/tree/main"
97+
}
12598
}
12699
}
127100
}
@@ -142,7 +115,6 @@ publishing {
142115
}
143116

144117
nexusStaging {
145-
packageGroup = PUBLISH_GROUP_ID
146118
stagingProfileId = sonatypeStagingProfileId
147119
username = ossrhUsername
148120
password = ossrhPassword

settings.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rootProject.name = 'module-graph'

0 commit comments

Comments
 (0)