|
1 |
| -import java.text.SimpleDateFormat |
2 | 1 | import java.util.*
|
3 | 2 |
|
4 |
| -rootProject.extra.set("artifactVersion", SimpleDateFormat("yyyy-MM-dd\'T\'HH-mm-ss").format(Date())) |
5 |
| - |
6 | 3 | buildscript {
|
7 |
| - repositories { |
8 |
| - mavenLocal() |
9 |
| - jcenter() |
10 |
| - gradlePluginPortal() |
11 |
| - mavenCentral() |
12 |
| - } |
| 4 | + repositories { |
| 5 | + gradlePluginPortal() |
| 6 | + mavenCentral() |
| 7 | + } |
13 | 8 | }
|
14 | 9 |
|
15 | 10 | plugins {
|
16 |
| - id("com.github.ben-manes.versions") version "0.33.0" |
17 |
| - id("com.jfrog.bintray") version "1.8.5" apply false |
18 |
| - id("net.ossindex.audit") version "0.4.11" |
19 |
| - id("io.freefair.github.package-registry-maven-publish") version "5.2.1" // apply false |
| 11 | + id("maven-publish") |
| 12 | + id("com.github.ben-manes.versions") version "0.36.0" |
| 13 | + id("net.ossindex.audit") version "0.4.11" |
| 14 | + id("io.freefair.maven-central.validate-poms") version "5.3.0" |
| 15 | + id("io.github.gradle-nexus.publish-plugin") version "1.0.0" |
20 | 16 | }
|
21 | 17 |
|
22 | 18 | val dependencyVersions = listOf(
|
23 |
| - "junit:junit:4.13", |
24 |
| - "org.codehaus.groovy:groovy:2.5.13", |
25 |
| - "org.codehaus.groovy:groovy-json:2.5.13", |
26 |
| - "org.codehaus.groovy:groovy-macro:2.5.13", |
27 |
| - "org.codehaus.groovy:groovy-nio:2.5.13", |
28 |
| - "org.codehaus.groovy:groovy-sql:2.5.13", |
29 |
| - "org.codehaus.groovy:groovy-templates:2.5.13", |
30 |
| - "org.codehaus.groovy:groovy-test:2.5.13", |
31 |
| - "org.codehaus.groovy:groovy-xml:2.5.13" |
| 19 | + "junit:junit:4.13", |
| 20 | + "org.codehaus.groovy:groovy:2.5.13", |
| 21 | + "org.codehaus.groovy:groovy-json:2.5.13", |
| 22 | + "org.codehaus.groovy:groovy-macro:2.5.13", |
| 23 | + "org.codehaus.groovy:groovy-nio:2.5.13", |
| 24 | + "org.codehaus.groovy:groovy-sql:2.5.13", |
| 25 | + "org.codehaus.groovy:groovy-templates:2.5.13", |
| 26 | + "org.codehaus.groovy:groovy-test:2.5.13", |
| 27 | + "org.codehaus.groovy:groovy-xml:2.5.13", |
| 28 | + "org.squareup.moshi:moshi:1.11.0", |
| 29 | + "org.squareup.moshi:moshi-kotlin:1.11.0", |
| 30 | + "org.squareup.okhttp3:okhttp:4.9.0", |
| 31 | + "org.squareup.okio:okio:2.9.0" |
32 | 32 | )
|
33 | 33 |
|
34 |
| -subprojects { |
35 |
| - configurations.all { |
36 |
| - resolutionStrategy { |
37 |
| - failOnVersionConflict() |
38 |
| - force(dependencyVersions) |
| 34 | +val dependencyGroupVersions = mapOf<String, String>() |
| 35 | + |
| 36 | +allprojects { |
| 37 | + configurations.all { |
| 38 | + resolutionStrategy { |
| 39 | + failOnVersionConflict() |
| 40 | + force(dependencyVersions) |
| 41 | + eachDependency { |
| 42 | + val forcedVersion = dependencyGroupVersions[requested.group] |
| 43 | + if (forcedVersion != null) { |
| 44 | + useVersion(forcedVersion) |
39 | 45 | }
|
| 46 | + } |
40 | 47 | }
|
| 48 | + } |
41 | 49 | }
|
42 | 50 |
|
43 | 51 | fun findProperty(s: String) = project.findProperty(s) as String?
|
44 | 52 |
|
45 |
| -rootProject.github { |
46 |
| - slug.set("${project.property("github.package-registry.owner")}/${project.property("github.package-registry.repository")}") |
47 |
| - username.set(System.getenv("GITHUB_ACTOR") ?: findProperty("github.package-registry.username")) |
48 |
| - token.set(System.getenv("GITHUB_TOKEN") ?: findProperty("github.package-registry.password")) |
49 |
| -} |
50 |
| - |
51 | 53 | tasks {
|
52 | 54 | wrapper {
|
53 | 55 | gradleVersion = "6.8.2"
|
54 | 56 | distributionType = Wrapper.DistributionType.ALL
|
55 | 57 | }
|
56 | 58 | }
|
57 | 59 |
|
| 60 | +val isSnapshot = project.version == "unspecified" |
| 61 | +nexusPublishing { |
| 62 | + repositories { |
| 63 | + if (!isSnapshot) { |
| 64 | + sonatype { |
| 65 | + // 'sonatype' is pre-configured for Sonatype Nexus (OSSRH) which is used for The Central Repository |
| 66 | + stagingProfileId.set(System.getenv("SONATYPE_STAGING_PROFILE_ID") ?: findProperty("sonatype.staging.profile.id")) //can reduce execution time by even 10 seconds |
| 67 | + username.set(System.getenv("SONATYPE_USERNAME") ?: findProperty("sonatype.username")) |
| 68 | + password.set(System.getenv("SONATYPE_PASSWORD") ?: findProperty("sonatype.password")) |
| 69 | + } |
| 70 | + } |
| 71 | + } |
| 72 | +} |
| 73 | + |
58 | 74 | project.apply("debug.gradle.kts")
|
0 commit comments