update gradle

This commit is contained in:
2024-08-13 01:22:53 +08:00
parent b5419b186e
commit 7ceb01d4e5
11 changed files with 242 additions and 406 deletions
+35 -94
View File
@@ -1,116 +1,57 @@
import groovy.io.FileType
plugins {
id 'java-library'
id 'maven-publish'
}
apply plugin: 'java-library'
apply plugin: 'maven-publish'
group = 'xyz.fortern'
version ='1.0.1'
group = 'com.mojang'
version = project.hasProperty('buildNumber') ? "${project.majorMinor}.${project.buildNumber}" : "${project.majorMinor}.0-SNAPSHOT"
buildscript {
repositories {
mavenCentral()
maven {
url "https://libraries.minecraft.net"
}
}
java {
sourceCompatibility = JavaVersion.VERSION_1_8
withSourcesJar()
}
repositories {
maven {
url "https://libraries.minecraft.net"
}
mavenCentral()
}
dependencies {
testCompile 'com.google.guava:guava:26.0-jre'
testCompile 'junit:junit-dep:4.11'
testCompile 'org.hamcrest:hamcrest-library:1.3'
testCompile 'org.mockito:mockito-core:1.10.19'
testCompile 'com.google.guava:guava-testlib:26.0-jre'
testCompile 'org.openjdk.jmh:jmh-core:1.21'
annotationProcessor 'org.openjdk.jmh:jmh-generator-annprocess:1.21'
}
task sourcesJar(type: Jar) {
classifier = 'sources'
from sourceSets.main.allSource
}
sourceSets {
main {
java {
srcDirs = ['src/main/java']
}
resources {
srcDirs = ['src/main/resources']
}
}
test {
java {
srcDirs = ['src/test/java']
}
resources {
srcDirs = ['src/test/resources']
}
}
}
artifacts {
archives jar
archives sourcesJar
}
test {
testLogging {
events "failed", "skipped"
showStandardStreams = true
showExceptions true
}
// JUnit Jupiter (Aggregator) https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter
testImplementation 'org.junit.jupiter:junit-jupiter:5.10.3'
// Guava: Google Core Libraries For Java https://mvnrepository.com/artifact/com.google.guava/guava
implementation 'com.google.guava:guava:33.2.1-jre'
// Guava Testing Library https://mvnrepository.com/artifact/com.google.guava/guava-testlib
testImplementation 'com.google.guava:guava-testlib:33.2.1-jre'
// Hamcrest Library https://mvnrepository.com/artifact/org.hamcrest/hamcrest-library
testImplementation 'org.hamcrest:hamcrest-library:3.0'
// Mockito Core https://mvnrepository.com/artifact/org.mockito/mockito-core
testImplementation 'org.mockito:mockito-core:1.10.19'
// JMH Core https://mvnrepository.com/artifact/org.openjdk.jmh/jmh-core
testImplementation 'org.openjdk.jmh:jmh-core:1.37'
// JMH Generators: Annotation Processors https://mvnrepository.com/artifact/org.openjdk.jmh/jmh-generator-annprocess
testImplementation 'org.openjdk.jmh:jmh-generator-annprocess:1.37'
}
publishing {
publications {
mavenJava(MavenPublication) {
maven(MavenPublication) {
from components.java
artifact sourcesJar
}
}
repositories {
maven {
name = 'ForternRelease'
url = "https://maven.fortern.xyz/repository/maven-releases/"
credentials {
username = findProperty('repo.fortern.user')
password = findProperty('repo.fortern.password')
}
}
}
}
task report {
tasks.register('report') {
doLast {
println "##vso[build.updatebuildnumber]${project.version}"
}
}
def publishDir = file("$buildDir/repo")
clean.doLast {
delete publishDir
}
if (version.endsWith("SNAPSHOT")) {
publishing.repositories {
mavenLocal()
}
} else {
publishing.repositories {
maven {
url "$buildDir/repo"
}
}
publish.doLast {
publishDir.eachFileRecurse {
if (!it.isFile()) {
return
}
// Remove junk files
if (it.name.contains(".xml") || it.name.contains(".md5")) {
it.delete()
}
}
}
}