|
| 1 | +plugins { |
| 2 | + id "java" |
| 3 | + id "maven-publish" |
| 4 | + id "signing" |
| 5 | + id "checkstyle" |
| 6 | + id "net.raphimc.class-token-replacer" version "1.1.3" |
| 7 | +} |
| 8 | + |
| 9 | +base { |
| 10 | + java.toolchain.languageVersion = JavaLanguageVersion.of(8) |
| 11 | + compileJava.options.encoding = compileTestJava.options.encoding = javadoc.options.encoding = "UTF-8" |
| 12 | + |
| 13 | + archivesName = project.maven_name ?: rootProject.maven_name |
| 14 | + group = project.maven_group ?: rootProject.maven_group |
| 15 | + version = project.maven_version ?: rootProject.maven_version |
| 16 | +} |
| 17 | + |
| 18 | +configurations { |
| 19 | + include |
| 20 | + |
| 21 | + implementation.extendsFrom include |
| 22 | + api.extendsFrom include |
| 23 | +} |
| 24 | + |
| 25 | +repositories { |
| 26 | + mavenCentral() |
| 27 | + maven { |
| 28 | + name = "lenni0451" |
| 29 | + url = "https://maven.lenni0451.net/everything" |
| 30 | + } |
| 31 | + maven { |
| 32 | + name = "jitpack" |
| 33 | + url = "https://jitpack.io" |
| 34 | + } |
| 35 | + maven { |
| 36 | + name = "sonatype snapshots" |
| 37 | + url "https://oss.sonatype.org/content/repositories/snapshots/" |
| 38 | + } |
| 39 | + |
| 40 | + //ivy { //include "waterfall:1.19:504@jar" |
| 41 | + // url "https://papermc.io/api/v2/projects" |
| 42 | + // patternLayout { |
| 43 | + // artifact "/[organisation]/versions/[module]/builds/[revision]/downloads/[organisation]-[module]-[revision].[ext]" |
| 44 | + // } |
| 45 | + // metadataSources { |
| 46 | + // artifact() |
| 47 | + // } |
| 48 | + //} |
| 49 | +} |
| 50 | + |
| 51 | +dependencies { |
| 52 | + if (new File(projectDir, "libs").exists()) { //Include all jars in the libs folder |
| 53 | + include fileTree(include: ["*.jar"], dir: "libs") |
| 54 | + } |
| 55 | + |
| 56 | + compileOnly "com.google.code.findbugs:jsr305:3.0.2" |
| 57 | + compileOnly "org.jetbrains:annotations:25.0.0" |
| 58 | + compileOnly(annotationProcessor("org.projectlombok:lombok:1.18.34")) |
| 59 | + //include "net.lenni0451:Reflect:1.0.0" |
| 60 | + |
| 61 | + testImplementation(platform("org.junit:junit-bom:5.11.1")) |
| 62 | + testImplementation "org.junit.jupiter:junit-jupiter" |
| 63 | + testRuntimeOnly "org.junit.platform:junit-platform-launcher" |
| 64 | + testCompileOnly(testAnnotationProcessor("org.projectlombok:lombok:1.18.34")) |
| 65 | +} |
| 66 | + |
| 67 | +sourceSets { |
| 68 | + main { |
| 69 | + classTokenReplacer { |
| 70 | + //Replace all instances of '${version}' with the project version |
| 71 | + property("\${version}", project.version) |
| 72 | + } |
| 73 | + } |
| 74 | +} |
| 75 | + |
| 76 | +java { |
| 77 | + withSourcesJar() |
| 78 | + withJavadocJar() |
| 79 | +} |
| 80 | + |
| 81 | +processResources { |
| 82 | + //Config file: "version: ${version}" |
| 83 | + inputs.properties( |
| 84 | + "version": project.maven_version |
| 85 | + ) |
| 86 | + |
| 87 | + filesMatching("config.yml") { |
| 88 | + expand( |
| 89 | + "version": project.maven_version |
| 90 | + ) |
| 91 | + } |
| 92 | +} |
| 93 | + |
| 94 | +artifacts { |
| 95 | + archives javadocJar, sourcesJar |
| 96 | +} |
| 97 | + |
| 98 | +jar { |
| 99 | + dependsOn configurations.include |
| 100 | + from { |
| 101 | + duplicatesStrategy = DuplicatesStrategy.EXCLUDE |
| 102 | + configurations.include.collect { |
| 103 | + zipTree(it) |
| 104 | + } |
| 105 | + } { |
| 106 | + exclude "META-INF/*.RSA", "META-INF/*.SF", "META-INF/*.DSA" |
| 107 | + } |
| 108 | + |
| 109 | + manifest { |
| 110 | + attributes( |
| 111 | + "Main-Class": "net.lenni0451.gradletemplate.Main", |
| 112 | + "Multi-Release": "true" |
| 113 | + ) |
| 114 | + } |
| 115 | +} |
| 116 | + |
| 117 | +test { |
| 118 | + useJUnitPlatform() |
| 119 | + testLogging { |
| 120 | + events "passed", "skipped", "failed" |
| 121 | + } |
| 122 | + maxParallelForks Runtime.runtime.availableProcessors() |
| 123 | +} |
| 124 | + |
| 125 | +publishing { |
| 126 | + repositories { |
| 127 | + maven { |
| 128 | + name = "reposilite" |
| 129 | + def releasesUrl = "https://maven.lenni0451.net/releases" |
| 130 | + def snapshotsUrl = "https://maven.lenni0451.net/snapshots" |
| 131 | + url = project.maven_version.endsWith("SNAPSHOT") ? snapshotsUrl : releasesUrl |
| 132 | + |
| 133 | + credentials(PasswordCredentials) |
| 134 | + authentication { |
| 135 | + basic(BasicAuthentication) |
| 136 | + } |
| 137 | + } |
| 138 | + maven { |
| 139 | + name = "ossrh" |
| 140 | + def releasesUrl = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/" |
| 141 | + def snapshotsUrl = "https://s01.oss.sonatype.org/content/repositories/snapshots/" |
| 142 | + url = project.maven_version.endsWith("SNAPSHOT") ? snapshotsUrl : releasesUrl |
| 143 | + |
| 144 | + credentials(PasswordCredentials) |
| 145 | + authentication { |
| 146 | + basic(BasicAuthentication) |
| 147 | + } |
| 148 | + } |
| 149 | + } |
| 150 | + publications { |
| 151 | + maven(MavenPublication) { |
| 152 | + artifactId = project.maven_name ?: rootProject.maven_name |
| 153 | + groupId = rootProject.maven_group |
| 154 | + version = rootProject.maven_version |
| 155 | + |
| 156 | + from components.java |
| 157 | + |
| 158 | + pom { |
| 159 | + name = rootProject.name |
| 160 | + description = rootProject.maven_description |
| 161 | + url = "https://github.com/" + rootProject.github_repo |
| 162 | + licenses { |
| 163 | + license { |
| 164 | + name = "MIT License" |
| 165 | + url = "https://github.com/" + rootProject.github_repo + "/blob/main/LICENSE" |
| 166 | + } |
| 167 | + } |
| 168 | + developers { |
| 169 | + developer { |
| 170 | + id = "Lenni0451" |
| 171 | + } |
| 172 | + } |
| 173 | + scm { |
| 174 | + connection = "scm:git:git://github.com/" + rootProject.github_repo + ".git" |
| 175 | + developerConnection = "scm:git:ssh://github.com/" + rootProject.github_repo + ".git" |
| 176 | + url = "github.com/" + rootProject.github_repo |
| 177 | + } |
| 178 | + } |
| 179 | + } |
| 180 | + } |
| 181 | +} |
| 182 | + |
| 183 | +checkstyle { |
| 184 | + toolVersion = "10.16.0" //Latest version for Java 8: 9.3 |
| 185 | + configFile = rootProject.file("config/checkstyle/checkstyle.xml") |
| 186 | +} |
| 187 | + |
| 188 | +signing { |
| 189 | + setRequired false |
| 190 | + sign configurations.archives |
| 191 | + sign publishing.publications.maven |
| 192 | +} |
| 193 | + |
| 194 | +project.tasks.withType(PublishToMavenRepository).forEach { |
| 195 | + it.dependsOn(project.tasks.withType(Sign)) |
| 196 | +} |
| 197 | +build.dependsOn(test) |
| 198 | +build.dependsOn(check) |
0 commit comments