generated from CottonMC/FabricStarter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
executable file
·151 lines (128 loc) · 4.91 KB
/
build.gradle.kts
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
import org.jfrog.gradle.plugin.artifactory.dsl.PublisherConfig
import groovy.lang.GroovyObject
plugins {
kotlin("jvm") version "1.3.61"
id("java")
id("eclipse")
id("idea")
id("fabric-loom") version "0.2.6-SNAPSHOT"
id("maven-publish")
id("com.jfrog.artifactory") version "4.9.0"
}
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
if(rootProject.file("private.gradle").exists()) { //Publishing details
apply(from = "private.gradle")
}
base {
archivesBaseName = project.findProperty("archives_base_name") as String
}
group = project.findProperty("maven_group") as String
version = project.findProperty("mod_version") as String + "+" + project.findProperty("minecraft_version") as String
minecraft {
}
repositories {
mavenCentral()
maven(url = "http://maven.fabricmc.net/") // Fabric maven - home of Fabric API and ModMenu
maven(url = "http://server.bbkr.space:8081/artifactory/libs-release") // Cotton maven - home of Cotton projects
maven(url = "https://maven.abusedmaster.xyz") // NerdHub maven - home of Cardinal Components
mavenCentral()
jcenter()
}
fun DependencyHandlerScope.includeAndExpose(dep: String) {
modImplementation(dep)
include(dep)
}
fun DependencyHandlerScope.includeKt(dep: String) {
val fullName = "org.jetbrains.kotlin:$dep:${project.findProperty("kotlin_version") as String}"
modImplementation(fullName)
include(fullName)
}
dependencies {
minecraft("com.mojang:minecraft:" + project.findProperty("minecraft_version") as String)
mappings("net.fabricmc:yarn:" + project.findProperty("minecraft_version") as String + "+build." + project.findProperty("yarn_build") as String + ":v2")
modImplementation("net.fabricmc:fabric-loader:" + project.findProperty("loader_version") as String)
modImplementation("net.fabricmc.fabric-api:fabric-api:" + project.findProperty("fabric_version") as String)
compileOnly("com.google.code.findbugs:jsr305:3.0.2")
modImplementation("net.fabricmc:fabric-language-kotlin:" + project.findProperty("kotlin_version") as String + "+build." + project.findProperty("fabric_kotlin_build") as String)
includeAndExpose("org.jetbrains.intellij.deps:trove4j:1.0.20181211")
includeKt("kotlin-script-runtime")
includeKt("kotlin-scripting-common")
includeKt("kotlin-scripting-jvm")
includeKt("kotlin-scripting-jvm-host-embeddable")
includeKt("kotlin-daemon-embeddable")
includeKt("kotlin-compiler-embeddable")
includeKt("kotlin-scripting-compiler-impl-embeddable")
includeKt("kotlin-scripting-compiler-embeddable")
includeKt("kotlin-scripting-jsr223-embeddable")
}
tasks.getByName<ProcessResources>("processResources") {
filesMatching("fabric.mod.json") {
expand(
mutableMapOf(
"version" to version
)
)
}
}
val remapJar = tasks.getByName("remapJar")
val remapSourcesJar = tasks.getByName("remapSourcesJar")
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this task, sources will not be generated.
val sourcesJar = tasks.create<Jar>("sourcesJar") {
classifier = "sources"
from(sourceSets["main"].allSource)
}
// configure the maven publication
publishing {
publications {
create("main", MavenPublication::class.java) {
// add all the jars that should be included when publishing to maven
//artifact(jar) {
// builtBy remapJar
//}
artifact (buildDir.absolutePath as String + "/libs/" + project.findProperty("archives_base_name") as String + "-" + project.findProperty("version") as String + ".jar") { //release jar - file location not provided anywhere in loom
classifier = null
builtBy (remapJar)
}
artifact (buildDir.absolutePath as String + "/libs/" + project.findProperty("archives_base_name") + "-" + project.findProperty("version") as String + "-dev.jar") { //release jar - file location not provided anywhere in loom
classifier = "dev"
builtBy (remapJar)
}
artifact(sourcesJar) {
builtBy (remapSourcesJar)
}
}
}
// select the repositories you want to publish to
repositories {
// uncomment to publish to the local maven
// mavenLocal()
}
}
artifactory {
if (project.hasProperty("artifactoryUsername")) {
setContextUrl("http://server.bbkr.space:8081/artifactory/")
publish(delegateClosureOf<PublisherConfig> {
repository(delegateClosureOf<GroovyObject> {
if ((version as String).contains("SNAPSHOT")) {
setProperty("repoKey", "libs-snapshot")
} else {
setProperty("repoKey", "libs-release")
}
setProperty("username", project.findProperty("artifactoryUsername"))
setProperty("password", project.findProperty("artifactoryPassword"))
})
defaults(delegateClosureOf<GroovyObject> {
invokeMethod("publications", "mavenJava")
setProperty("publishPom", true)
setProperty("publishArtifacts", true)
})
})
} else {
println("Cannot configure artifactory; please define ext.artifactoryUsername and ext.artifactoryPassword before running artifactoryPublish")
}
}