|
1 | | -import org.gradle.api.internal.artifacts.dsl.LazyPublishArtifact |
| 1 | +import com.jfrog.bintray.gradle.BintrayExtension |
2 | 2 | import org.jmailen.gradle.kotlinter.support.ReporterType |
3 | 3 |
|
4 | 4 | plugins { |
@@ -49,67 +49,130 @@ subprojects { |
49 | 49 | reporters = arrayOf(ReporterType.plain.name, ReporterType.checkstyle.name) |
50 | 50 | } |
51 | 51 |
|
52 | | - val sourcesJar by tasks.registering(Jar::class) { |
53 | | - from(sourceSets["main"].allSource) |
54 | | - archiveClassifier.set("sources") |
55 | | - } |
| 52 | + val artifactRepo: String by project |
| 53 | + val artifactName: String by project |
| 54 | + val artifactDesc: String by project |
| 55 | + val artifactUserOrg: String by project |
| 56 | + val artifactUrl: String by project |
| 57 | + val artifactScm: String by project |
| 58 | + val artifactLicenseName: String by project |
| 59 | + val artifactLicenseUrl: String by project |
56 | 60 |
|
57 | | - val doc by tasks.creating(Javadoc::class) { |
58 | | - isFailOnError = false |
59 | | - source = sourceSets["main"].allJava |
60 | | - } |
| 61 | + val artifactPublish: String by project |
| 62 | + val artifactGroupId: String by project |
| 63 | + version = artifactPublish |
| 64 | + group = artifactGroupId |
61 | 65 |
|
62 | | - val artifactVersion: String by project |
63 | | - val artifactGroup: String by project |
64 | | - version = artifactVersion |
65 | | - group = artifactGroup |
| 66 | + //publishing |
| 67 | + configure<PublishingExtension> { |
66 | 68 |
|
67 | | - bintray { |
68 | | - user = findProperty("BINTRAY_USER") as? String |
69 | | - key = findProperty("BINTRAY_KEY") as? String |
70 | | - setPublications(project.name) |
71 | | - with(pkg) { |
72 | | - repo = "maven" |
73 | | - name = "Forge" |
74 | | - desc = "Functional style JSON parsing written in Kotlin" |
75 | | - userOrg = "kittinunf" |
76 | | - websiteUrl = "https://github.com/kittinunf/Forge" |
77 | | - vcsUrl = "https://github.com/kittinunf/Forge" |
78 | | - setLicenses("MIT") |
79 | | - with(version) { |
80 | | - name = artifactVersion |
81 | | - } |
| 69 | + val sourceSets = project.the<SourceSetContainer>() |
| 70 | + |
| 71 | + val sourcesJar by tasks.registering(Jar::class) { |
| 72 | + from(sourceSets["main"].allSource) |
| 73 | + classifier = "sources" |
82 | 74 | } |
83 | | - } |
84 | 75 |
|
85 | | - val javadocJar by tasks.creating(Jar::class) { |
86 | | - val doc by tasks |
87 | | - dependsOn(doc) |
88 | | - from(doc) |
| 76 | + val javadocJar by tasks.creating(Jar::class) { |
| 77 | + val doc by tasks.creating(Javadoc::class) { |
| 78 | + isFailOnError = false |
| 79 | + source = sourceSets["main"].allJava |
| 80 | + } |
89 | 81 |
|
90 | | - archiveClassifier.set("javadoc") |
91 | | - } |
| 82 | + dependsOn(doc) |
| 83 | + from(doc) |
| 84 | + |
| 85 | + classifier = "javadoc" |
| 86 | + } |
92 | 87 |
|
93 | | - publishing { |
94 | 88 | publications { |
95 | 89 | register(project.name, MavenPublication::class) { |
96 | 90 | from(components["java"]) |
97 | | - artifact(LazyPublishArtifact(sourcesJar)) |
| 91 | + artifact(sourcesJar.get()) |
98 | 92 | artifact(javadocJar) |
99 | | - groupId = artifactGroup |
| 93 | + groupId = artifactGroupId |
100 | 94 | artifactId = project.name |
101 | | - version = artifactVersion |
| 95 | + version = artifactPublish |
| 96 | + |
102 | 97 | pom { |
| 98 | + name.set(project.name) |
| 99 | + description.set(artifactDesc) |
| 100 | + |
| 101 | + packaging = "jar" |
| 102 | + url.set(artifactUrl) |
| 103 | + |
103 | 104 | licenses { |
104 | 105 | license { |
105 | 106 | name.set("MIT License") |
106 | 107 | url.set("http://www.opensource.org/licenses/mit-license.php") |
107 | 108 | } |
108 | 109 | } |
| 110 | + |
| 111 | + developers { |
| 112 | + developer { |
| 113 | + name.set("kittinunf") |
| 114 | + } |
| 115 | + developer { |
| 116 | + name.set("babedev") |
| 117 | + } |
| 118 | + developer { |
| 119 | + name.set("janjaali") |
| 120 | + } |
| 121 | + } |
| 122 | + |
| 123 | + contributors { |
| 124 | + // https://github.com/kittinunf/Result/graphs/contributors |
| 125 | + contributor { |
| 126 | + name.set("pgreze") |
| 127 | + } |
| 128 | + } |
| 129 | + |
| 130 | + scm { |
| 131 | + url.set(artifactUrl) |
| 132 | + connection.set(artifactScm) |
| 133 | + developerConnection.set(artifactScm) |
| 134 | + } |
109 | 135 | } |
110 | 136 | } |
111 | 137 | } |
112 | 138 | } |
| 139 | + |
| 140 | + // bintray |
| 141 | + configure<BintrayExtension> { |
| 142 | + user = findProperty("BINTRAY_USER") as? String |
| 143 | + key = findProperty("BINTRAY_KEY") as? String |
| 144 | + setPublications(project.name) |
| 145 | + publish = true |
| 146 | + pkg.apply { |
| 147 | + repo = artifactRepo |
| 148 | + name = artifactName |
| 149 | + desc = artifactDesc |
| 150 | + userOrg = artifactUserOrg |
| 151 | + websiteUrl = artifactUrl |
| 152 | + vcsUrl = artifactUrl |
| 153 | + setLicenses(artifactLicenseName) |
| 154 | + version.apply { |
| 155 | + name = artifactPublish |
| 156 | + gpg(delegateClosureOf<BintrayExtension.GpgConfig> { |
| 157 | + sign = true |
| 158 | + passphrase = System.getenv("GPG_PASSPHRASE") ?: "" |
| 159 | + }) |
| 160 | + } |
| 161 | + } |
| 162 | + } |
| 163 | + |
| 164 | + // jacoco |
| 165 | + configure<JacocoPluginExtension> { |
| 166 | + toolVersion = extra.get("jacoco") as String |
| 167 | + } |
| 168 | + |
| 169 | + tasks.withType<JacocoReport> { |
| 170 | + reports { |
| 171 | + html.isEnabled = true |
| 172 | + xml.isEnabled = true |
| 173 | + csv.isEnabled = false |
| 174 | + } |
| 175 | + } |
113 | 176 | } |
114 | 177 |
|
115 | 178 | fun <T> NamedDomainObjectContainer<T>.release(configure: T.() -> Unit) = getByName("release", configure) |
|
0 commit comments