aboutsummaryrefslogtreecommitdiff
path: root/build.gradle
blob: f737c4978329178b34201161a3313a424bbba60c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
//file:noinspection GroovyAssignabilityCheck

plugins {
    id("java")
    id("checkstyle")
    id("com.github.spotbugs").version("5.0.5")
    id("org.cadixdev.licenser").version("0.6.1")
    id("com.github.johnrengelman.shadow").version("7.1.2")
    id("maven-publish")
}

setGroup("net.elytrium")
setVersion("1.0.4-SNAPSHOT")

compileJava {
    getOptions().setEncoding("UTF-8")
}

java {
    setSourceCompatibility(JavaVersion.VERSION_11)
    setTargetCompatibility(JavaVersion.VERSION_11)
}

repositories {
    mavenCentral()

    maven {
        setName("elytrium-repo")
        setUrl("https://maven.elytrium.net/repo/")
    }
    maven {
        setName("papermc-repo")
        setUrl("https://papermc.io/repo/repository/maven-public/")
    }
    maven {
        setName("opencollab-repo")
        setUrl("https://repo.opencollab.dev/maven-snapshots/")
    }
}

task javadocJar(type: Jar) {
    getArchiveClassifier().set("javadoc")
    from(javadoc)
}

task sourcesJar(type: Jar) {
    getArchiveClassifier().set("sources")
    from(sourceSets.main.getAllSource())
}

publishing {
    repositories {
        maven {
            credentials {
                setUsername(System.getenv("PUBLISH_USERNAME"))
                setPassword(System.getenv("PUBLISH_PASSWORD"))
            }

            setName("elytrium-repo")
            setUrl("https://maven.elytrium.net/repo/")
        }
    }

    publications {
        maven(MavenPublication) {
            from(components.java)

            artifact(javadocJar)
            artifact(sourcesJar)
        }
    }
}

dependencies {
    compileOnly("net.elytrium:limboapi-api:1.0.4-SNAPSHOT")

    compileOnly("com.velocitypowered:velocity-api:3.1.2-SNAPSHOT")
    annotationProcessor("com.velocitypowered:velocity-api:3.1.2-SNAPSHOT")

    compileOnly("org.geysermc.floodgate:api:2.1.1-SNAPSHOT")

    implementation("at.favre.lib:bcrypt:0.9.0")
    implementation("dev.samstevens.totp:totp:1.7.1")

    implementation("com.j256.ormlite:ormlite-jdbc:6.1")

    implementation("com.h2database:h2:1.4.200")
    implementation("mysql:mysql-connector-java:8.0.28")
    implementation("org.postgresql:postgresql:42.3.1")

    implementation("org.bstats:bstats-velocity:2.2.1")
    implementation("de.mkammerer:argon2-jvm-nolibs:2.11")

    compileOnly("com.github.spotbugs:spotbugs-annotations:4.5.3")
}

shadowJar {
    getArchiveClassifier().set("")

    exclude("META-INF/maven/**")
    exclude("META-INF/INFO_BIN")
    exclude("META-INF/INFO_SRC")
    exclude("google/protobuf/**")
    exclude("com/google/protobuf/**")
    exclude("com/mysql/cj/x/**")
    exclude("com/mysql/cj/xdevapi/**")
    exclude("org/apache/commons/codec/language/**")
    exclude("org/checkerframework/**")
    exclude("**/package-info.class")

    minimize()

    // Why are we increasing the size of the plugin if we can do that? :thinking:
    relocate("org.bstats", "net.elytrium.limboapi.thirdparty.org.bstats")
    exclude("org/bstats/**")

    relocate("at.favre.lib", "net.elytrium.limboauth.thirdparty.at.favre.lib")
    relocate("com.j256.ormlite", "net.elytrium.limboauth.thirdparty.com.j256.ormlite")
    relocate("com.mysql", "net.elytrium.limboauth.thirdparty.com.mysql")
    relocate("dev.samstevens.totp", "net.elytrium.limboauth.thirdparty.dev.samstevens.totp")
    relocate("org.apache.commons.codec", "net.elytrium.limboauth.thirdparty.org.apache.commons.codec")
    relocate("org.h2", "net.elytrium.limboauth.thirdparty.org.h2")
    relocate("org.postgresql", "net.elytrium.limboauth.thirdparty.org.postgresql")
}

license {
    setHeader(file("HEADER.txt"))
}

checkstyle {
    setToolVersion("9.2.1")
    setConfigFile(file("${this.getRootDir()}/config/checkstyle/checkstyle.xml"))
    setConfigProperties("configDirectory": "${this.getRootDir()}/config/checkstyle")

    // The build should immediately fail if we have errors.
    setMaxErrors(0)
    setMaxWarnings(0)
}

spotbugsMain {
    setExcludeFilter(file("${this.getRootDir()}/config/spotbugs/suppressions.xml"))

    reports {
        html {
            getRequired().set(true)
            getOutputLocation().set(file("${this.getBuildDir()}/reports/spotbugs/main/spotbugs.html"))
            setStylesheet("fancy-hist.xsl")
        }
    }
}

sourceSets.main.getJava().srcDir(getTasks().register("generateTemplates", Copy) { task ->
    task.getInputs().properties("version": getVersion())

    task.from(file("src/main/templates"))
        .into(getLayout().getBuildDirectory().dir("generated/sources/templates"))
        .expand("version": getVersion())
}.map {
    it.getOutputs()
})

assemble.dependsOn(shadowJar)