@@ -45,24 +45,6 @@ kotlin {
4545 }
4646}
4747
48- tasks.withType<Jar > {
49- manifest {
50- attributes(" Automatic-Module-Name" to " com.asarkar.grpc.test" )
51- }
52- archiveBaseName = rootProject.name
53- }
54-
55- tasks.withType<Test > {
56- useJUnitPlatform()
57- testLogging {
58- showStandardStreams = true
59- }
60- exclude(" **/ignore/**" )
61- // Suppress warning: Sharing is only supported for boot loader classes...
62- // https://stackoverflow.com/q/54205486/839733
63- jvmArgs(" -Xshare:off" )
64- }
65-
6648val ci: Boolean by lazy { System .getenv(" CI" ) != null }
6749
6850ktlint {
@@ -73,15 +55,6 @@ ktlint {
7355 additionalEditorconfig = mapOf (" max_line_length" to " 100" )
7456}
7557
76- tasks.withType<KtLintFormatTask > {
77- enabled = ! ci
78- }
79-
80- tasks.withType<KtLintCheckTask > {
81- val fmtTaskName = name.replace(" Check" , " Format" )
82- dependsOn(tasks.named(fmtTaskName))
83- }
84-
8558val gitHubUsername: String by project
8659val gitHubRepo: String by lazy {
8760 System .getenv(" GITHUB_REPOSITORY" ) ? : " $gitHubUsername /${rootProject.name} "
@@ -110,11 +83,6 @@ val licenseUrl: String by project
11083
11184version = projectVersion
11285
113- // https://github.com/vanniktech/gradle-maven-publish-plugin/issues/966
114- tasks.withType<JavadocJar > {
115- archiveFileName = " ${rootProject.name} -javadoc.jar"
116- }
117-
11886mavenPublishing {
11987 configure(
12088 KotlinJvm (
@@ -150,3 +118,43 @@ mavenPublishing {
150118 }
151119 }
152120}
121+
122+ /*
123+ DO NOT use existing(Task::class) for configuring tasks.
124+ existing() if not referenced from another task is dropped on the floor!
125+ Use withTask() instead.
126+ */
127+ tasks {
128+ withType<Jar > {
129+ manifest {
130+ attributes(" Automatic-Module-Name" to " com.asarkar.grpc.test" )
131+ }
132+ archiveBaseName = rootProject.name
133+ }
134+
135+ test {
136+ useJUnitPlatform()
137+ testLogging {
138+ showStandardStreams = true
139+ }
140+ exclude(" **/ignore/**" )
141+ // Suppress warning: Sharing is only supported for boot loader classes...
142+ // https://stackoverflow.com/q/54205486/839733
143+ jvmArgs(" -Xshare:off" )
144+ }
145+
146+ // https://github.com/vanniktech/gradle-maven-publish-plugin/issues/966
147+ withType<JavadocJar > {
148+ archiveFileName = " ${rootProject.name} -javadoc.jar"
149+ }
150+
151+ withType<KtLintFormatTask > {
152+ enabled = ! ci
153+ }
154+
155+ withType<KtLintCheckTask > {
156+ val fmtTaskName = name.replace(" Check" , " Format" )
157+ val fmtTask by named(fmtTaskName)
158+ dependsOn(fmtTask)
159+ }
160+ }
0 commit comments