|
1 | 1 | plugins { |
2 | | - id "org.jetbrains.kotlin.jvm" version "1.5.31" |
| 2 | + id 'org.jetbrains.kotlin.jvm' version '1.5.31' |
| 3 | + id 'io.github.gradle-nexus.publish-plugin' version '1.1.0' |
| 4 | + id 'maven-publish' |
| 5 | + id 'signing' |
3 | 6 | } |
4 | 7 |
|
5 | | -apply plugin: 'idea' |
6 | | -apply plugin: 'kotlin' |
7 | | - |
8 | 8 | repositories { |
9 | 9 | mavenCentral() |
10 | 10 | } |
11 | 11 |
|
12 | 12 | dependencies { |
13 | | - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.31" |
| 13 | + implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.31' |
14 | 14 |
|
15 | 15 | testImplementation 'org.jetbrains.kotlin:kotlin-test-junit:1.5.31' |
16 | 16 | testImplementation 'junit:junit:4.13.2' |
17 | 17 | } |
18 | 18 |
|
| 19 | +compileJava { |
| 20 | + sourceCompatibility = '1.8' |
| 21 | + targetCompatibility = '1.8' |
| 22 | +} |
| 23 | + |
19 | 24 | sourceSets { |
20 | 25 | main.kotlin.srcDirs += 'src/main/kotlin' |
21 | 26 | } |
| 27 | + |
| 28 | +group = GROUP |
| 29 | +version = VERSION_NAME |
| 30 | + |
| 31 | +java { |
| 32 | + withJavadocJar() |
| 33 | + withSourcesJar() |
| 34 | +} |
| 35 | + |
| 36 | +// Publish and release with: |
| 37 | +// ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository |
| 38 | +// Both tasks must be executed in one pass |
| 39 | +// https://github.com/gradle-nexus/publish-plugin/ |
| 40 | +nexusPublishing { |
| 41 | + repositories { |
| 42 | + sonatype { |
| 43 | + nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/")) |
| 44 | + snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")) |
| 45 | + } |
| 46 | + } |
| 47 | +} |
| 48 | + |
| 49 | +def configurePom(pom) { |
| 50 | + pom.name = POM_NAME |
| 51 | + pom.packaging = POM_PACKAGING |
| 52 | + pom.description = POM_DESCRIPTION |
| 53 | + pom.url = POM_URL |
| 54 | + |
| 55 | + pom.scm { |
| 56 | + url = POM_SCM_URL |
| 57 | + connection = POM_SCM_CONNECTION |
| 58 | + developerConnection = POM_SCM_DEV_CONNECTION |
| 59 | + } |
| 60 | + |
| 61 | + pom.licenses { |
| 62 | + license { |
| 63 | + name = POM_LICENCE_NAME |
| 64 | + url = POM_LICENCE_URL |
| 65 | + distribution = POM_LICENCE_DIST |
| 66 | + } |
| 67 | + } |
| 68 | + |
| 69 | + pom.developers { |
| 70 | + developer { |
| 71 | + id = POM_DEVELOPER_ID |
| 72 | + name = POM_DEVELOPER_NAME |
| 73 | + } |
| 74 | + } |
| 75 | +} |
| 76 | + |
| 77 | +publishing { |
| 78 | + repositories { |
| 79 | + maven { |
| 80 | + def releasesRepoUrl = 'https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/' |
| 81 | + def snapshotsRepoUrl = 'https://s01.oss.sonatype.org/content/repositories/snapshots/' |
| 82 | + url = !VERSION_NAME.contains("SNAPSHOT") ? releasesRepoUrl : snapshotsRepoUrl |
| 83 | + |
| 84 | + credentials(PasswordCredentials) { |
| 85 | + username = SONATYPE_NEXUS_USERNAME |
| 86 | + password = SONATYPE_NEXUS_PASSWORD |
| 87 | + } |
| 88 | + } |
| 89 | + } |
| 90 | + |
| 91 | + publications { |
| 92 | + mavenJava(MavenPublication) { |
| 93 | + artifactId = POM_ARTIFACT_ID |
| 94 | + groupId = GROUP |
| 95 | + version = VERSION_NAME |
| 96 | + |
| 97 | + configurePom(pom) |
| 98 | + |
| 99 | + from components.java |
| 100 | + } |
| 101 | + } |
| 102 | +} |
| 103 | + |
| 104 | +signing { |
| 105 | + sign publishing.publications.mavenJava |
| 106 | +} |
0 commit comments