forked from CinemaMod/mcef
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbuild.gradle
147 lines (124 loc) · 4 KB
/
build.gradle
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
plugins {
id 'fabric-loom'
id 'maven-publish'
id 'idea'
}
def getCheckedOutGitCommitHash(Project mcefParent) {
def gitFolder = "$mcefParent.projectDir/.git/modules/java-cef/"
def takeFromHash = 40
/*
* '.git/HEAD' contains either
* in case of detached head: the currently checked out commit hash
* otherwise: a reference to a file containing the current commit hash
*/
def gitHeadFile = new File(gitFolder + "HEAD");
if (gitHeadFile.exists()) {
def head = gitHeadFile.text.split(":") // .git/HEAD
def isCommit = head.length == 1 // e5a7c79edabbf7dd39888442df081b1c9d8e88fd
// def isRef = head.length > 1 // ref: refs/heads/master
if (isCommit) return head[0].trim().take(takeFromHash) // e5a7c79edabb
def refHead = new File(gitFolder + head[1].trim()) // .git/refs/heads/master
refHead.text.trim().take takeFromHash
} else {
return ""
}
}
tasks.register('cloneJcef', Exec) {
commandLine 'git', 'submodule', 'update', '--init', '--recursive', 'java-cef'
}
tasks.register('generateJcefCommitFile') {
doLast {
def commitHash = getCheckedOutGitCommitHash(project)
if (!commitHash.isEmpty()) {
file("$buildDir/jcef.commit").text = commitHash
} else {
throw new GradleException("Unable to determine JCEF commit hash.")
}
}
}
version = project.mod_version
group = project.maven_group
base {
archivesName = project.archives_base_name
}
repositories {
mavenCentral()
mavenLocal()
maven { url = 'https://maven.fabricmc.net/' }
}
dependencies {
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
implementation 'org.apache.commons:commons-exec:1.3'
}
sourceSets {
jcef {
java {
srcDir "java-cef/java"
exclude "**/tests/**"
}
}
main {
compileClasspath += jcef.output
runtimeClasspath += jcef.output
}
}
processResources {
filesMatching('fabric.mod.json') {
expand 'mod_id': mod_id,
'mod_name': mod_name,
'mod_vendor': mod_vendor,
'mod_version': mod_version,
'minecraft_version': minecraft_version,
'loader_version': loader_version
}
inputs.property "version", project.version
dependsOn processJcefResources
dependsOn generateJcefCommitFile
}
tasks.withType(JavaCompile).configureEach {
it.options.release = 21
}
jar {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
manifest {
attributes(['Specification-Title' : archives_base_name,
'Specification-Vendor' : group,
'Specification-Version' : "1",
'Implementation-Title' : archives_base_name,
'Implementation-Version' : mod_version,
'Implementation-Vendor' : group,
'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
'java-cef-commit' : getCheckedOutGitCommitHash(project)
])
}
from sourceSets.jcef.output.classesDirs
from sourceSets.jcef.output.resourcesDir
from("LICENSE") {
rename { "${it}_${project.base.archivesName.get()}"}
}
from("$buildDir/jcef.commit")
}
java {
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this line, sources will not be generated.
withSourcesJar()
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}
idea {
module {
excludeDirs += file("java-cef/java/tests")
inheritOutputDirs true
}
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
}
group = 'com.github.CCBlueX'