|
| 1 | +import com.github.benmanes.gradle.versions.VersionsPlugin |
| 2 | +import org.gradle.api.tasks.testing.logging.TestExceptionFormat |
| 3 | + |
| 4 | +val ossrhUsername: String? = System.getenv("OSSRH_USERNAME") |
| 5 | +val ossrhPassword: String? = System.getenv("OSSRH_PASSWORD") |
| 6 | +val signingPassword: String? = System.getenv("SIGNING_PASSWORD") |
| 7 | +val gitCommit = System.getenv("TRAVIS_COMMIT") ?: "" |
| 8 | + |
| 9 | +tasks.wrapper { |
| 10 | + gradleVersion = "5.4" |
| 11 | + distributionType = Wrapper.DistributionType.ALL |
| 12 | +} |
| 13 | + |
| 14 | +plugins { |
| 15 | + id("com.github.ben-manes.versions") version "0.21.0" |
| 16 | + idea |
| 17 | +} |
| 18 | + |
| 19 | +allprojects { |
| 20 | + apply<IdeaPlugin>() |
| 21 | + apply<VersionsPlugin>() |
| 22 | + |
| 23 | + repositories { |
| 24 | + mavenCentral() |
| 25 | + } |
| 26 | +} |
| 27 | + |
| 28 | +val javaVersion = JavaVersion.VERSION_1_8 |
| 29 | + |
| 30 | +idea { |
| 31 | + project.jdkName = javaVersion.name |
| 32 | +} |
| 33 | + |
| 34 | +subprojects { |
| 35 | + group = "ru.bozaro.gitlfs" |
| 36 | + version = "0.13.0-SNAPSHOT" |
| 37 | + |
| 38 | + apply<JavaPlugin>() |
| 39 | + apply<MavenPublishPlugin>() |
| 40 | + |
| 41 | + configure<JavaPluginExtension> { |
| 42 | + sourceCompatibility = javaVersion |
| 43 | + targetCompatibility = javaVersion |
| 44 | + } |
| 45 | + |
| 46 | + val compile by configurations |
| 47 | + val testCompile by configurations |
| 48 | + |
| 49 | + dependencies { |
| 50 | + compile("org.jetbrains:annotations:17.0.0") |
| 51 | + |
| 52 | + testCompile("com.google.guava:guava:27.1-jre") |
| 53 | + testCompile("org.testng:testng:6.14.3") |
| 54 | + } |
| 55 | + |
| 56 | + idea { |
| 57 | + module { |
| 58 | + isDownloadJavadoc = true |
| 59 | + isDownloadSources = true |
| 60 | + |
| 61 | + // Workaround for https://youtrack.jetbrains.com/issue/IDEA-175172 |
| 62 | + outputDir = file("build/classes/main") |
| 63 | + testOutputDir = file("build/classes/test") |
| 64 | + } |
| 65 | + } |
| 66 | + |
| 67 | + tasks.withType<JavaCompile> { |
| 68 | + options.encoding = "UTF-8" |
| 69 | + } |
| 70 | + |
| 71 | + tasks.withType<Test> { |
| 72 | + useTestNG { |
| 73 | + testLogging { |
| 74 | + exceptionFormat = TestExceptionFormat.FULL |
| 75 | + showStandardStreams = true |
| 76 | + } |
| 77 | + } |
| 78 | + } |
| 79 | + |
| 80 | + val javadoc by tasks.getting(Javadoc::class) { |
| 81 | + (options as? CoreJavadocOptions)?.addStringOption("Xdoclint:none", "-quiet") |
| 82 | + } |
| 83 | + |
| 84 | + val javadocJar by tasks.creating(Jar::class) { |
| 85 | + from(javadoc) |
| 86 | + archiveClassifier.set("javadoc") |
| 87 | + } |
| 88 | + |
| 89 | + val sourcesJar by tasks.creating(Jar::class) { |
| 90 | + val sourceSets: SourceSetContainer by project |
| 91 | + from(sourceSets["main"].allSource) |
| 92 | + archiveClassifier.set("sources") |
| 93 | + } |
| 94 | + |
| 95 | + val secretKeyRingFile = "${rootProject.projectDir}/secring.gpg" |
| 96 | + |
| 97 | + if (signingPassword != null && file(secretKeyRingFile).exists()) { |
| 98 | + extra["signing.secretKeyRingFile"] = secretKeyRingFile |
| 99 | + extra["signing.keyId"] = "4B49488E" |
| 100 | + extra["signing.password"] = signingPassword |
| 101 | + |
| 102 | + configure<SigningExtension> { |
| 103 | + val publications: PublicationContainer by project |
| 104 | + sign(publications) |
| 105 | + } |
| 106 | + } |
| 107 | + |
| 108 | + configure<PublishingExtension> { |
| 109 | + publications { |
| 110 | + create<MavenPublication>(project.name) { |
| 111 | + from(components["java"]) |
| 112 | + |
| 113 | + artifact(sourcesJar) |
| 114 | + artifact(javadocJar) |
| 115 | + |
| 116 | + pom { |
| 117 | + url.set("https://github.com/bozaro/git-lfs-java") |
| 118 | + |
| 119 | + scm { |
| 120 | + connection.set("scm:git:git://github.com/bozaro/git-lfs-java.git") |
| 121 | + tag.set(gitCommit) |
| 122 | + url.set("https://github.com/bozaro/git-lfs-java") |
| 123 | + } |
| 124 | + |
| 125 | + licenses { |
| 126 | + license { |
| 127 | + name.set("Lesser General Public License, version 3 or greater") |
| 128 | + url.set("http://www.gnu.org/licenses/lgpl.html") |
| 129 | + } |
| 130 | + } |
| 131 | + |
| 132 | + developers { |
| 133 | + developer { |
| 134 | + id.set("bozaro") |
| 135 | + name.set("Artem V. Navrotskiy") |
| 136 | + |
| 137 | + } |
| 138 | + |
| 139 | + developer { |
| 140 | + id.set("slonopotamus") |
| 141 | + name.set("Marat Radchenko") |
| 142 | + |
| 143 | + } |
| 144 | + } |
| 145 | + } |
| 146 | + } |
| 147 | + } |
| 148 | + |
| 149 | + if (ossrhUsername != null) { |
| 150 | + repositories { |
| 151 | + maven { |
| 152 | + val releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/" |
| 153 | + val snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots/" |
| 154 | + url = uri(if (version.toString().endsWith("SNAPSHOT")) snapshotsRepoUrl else releasesRepoUrl) |
| 155 | + |
| 156 | + credentials { |
| 157 | + username = ossrhUsername |
| 158 | + password = ossrhPassword |
| 159 | + } |
| 160 | + } |
| 161 | + } |
| 162 | + } |
| 163 | + } |
| 164 | +} |
0 commit comments