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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
|
import net.minecraftforge.artifactural.buildscript.JarTransformationTask
import org.objectweb.asm.Opcodes
import org.objectweb.asm.tree.InsnNode
import org.objectweb.asm.tree.MethodInsnNode
import org.objectweb.asm.Label
plugins {
id 'java-library'
id 'maven-publish'
id 'eclipse'
id 'org.cadixdev.licenser' version '0.6.1'
id 'net.minecraftforge.gradleutils' version '2.+'
}
group = 'net.minecraftforge'
version = gradleutils.getTagOffsetVersion()
println('Version: ' + version + ' Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch'))
sourceSets {
api
shared
gradlecomp
}
repositories {
mavenCentral()
maven {
url = 'https://maven.minecraftforge.net'
}
}
configurations {
sharedImplementation.extendsFrom apiImplementation
gradlecompImplementation.extendsFrom sharedImplementation
implementation.extendsFrom sharedImplementation
implementation.extendsFrom gradlecompImplementation
}
dependencies {
sharedImplementation sourceSets.api.output
gradlecompImplementation sourceSets.shared.output
gradlecompImplementation gradleApi()
gradlecompImplementation 'com.google.guava:guava:30.1-jre'
gradlecompImplementation 'net.minecraftforge:unsafe:0.2.0'
implementation sourceSets.api.output
implementation sourceSets.shared.output
implementation sourceSets.gradlecomp.output
}
tasks.withType(JavaCompile).configureEach {
options.encoding = 'utf-8'
options.deprecation = true
}
java {
toolchain.languageVersion = JavaLanguageVersion.of(8)
withSourcesJar()
}
tasks.register('transformJar', JarTransformationTask).configure {
addTransformer('net/minecraftforge/artifactural/gradle/GradleRepositoryAdapter') {
it.methods.find {
it.name == '<init>' && it.desc == '(Lnet/minecraftforge/artifactural/api/repository/Repository;Lorg/gradle/api/internal/artifacts/repositories/DefaultMavenLocalArtifactRepository;)V'
}?.tap {
it.instructions.find {
it instanceof InsnNode && it.opcode == Opcodes.ACONST_NULL
}?.tap(it.instructions.&remove)
it.instructions.find {
it instanceof MethodInsnNode && it.owner == 'org/gradle/api/internal/artifacts/repositories/AbstractArtifactRepository' && it.name == '<init>'
}?.tap { (it as MethodInsnNode).desc = '(Lorg/gradle/api/model/ObjectFactory;)V' }
}
}
addTransformer('net/minecraftforge/artifactural/gradle/GradleRepositoryAdapter$1$1') { clazz ->
{
final method = clazz.visitMethod(Opcodes.ACC_PUBLIC, 'resolveArtifact', '(Lorg/gradle/internal/component/model/ComponentArtifactMetadata;Lorg/gradle/internal/component/model/ModuleSources;Lorg/gradle/internal/resolve/result/BuildableArtifactResolveResult;)V', null, new String[] {})
final l0 = new Label()
method.visitLabel(l0)
method.visitVarInsn(Opcodes.ALOAD, 0)
method.visitFieldInsn(Opcodes.GETFIELD, 'net/minecraftforge/artifactural/gradle/GradleRepositoryAdapter$1$1', 'val$delegate', 'Lorg/gradle/api/internal/artifacts/ivyservice/ivyresolve/ModuleComponentRepositoryAccess;')
method.visitVarInsn(Opcodes.ALOAD, 1)
method.visitVarInsn(Opcodes.ALOAD, 2)
method.visitVarInsn(Opcodes.ALOAD, 3)
method.visitMethodInsn(Opcodes.INVOKEINTERFACE, 'org/gradle/api/internal/artifacts/ivyservice/ivyresolve/ModuleComponentRepositoryAccess', 'resolveArtifact', '(Lorg/gradle/internal/component/model/ComponentArtifactMetadata;Lorg/gradle/internal/component/model/ModuleSources;Lorg/gradle/internal/resolve/result/BuildableArtifactResolveResult;)V', true)
final l1 = new Label()
method.visitLabel(l1)
method.visitInsn(Opcodes.RETURN)
final l2 = new Label()
method.visitLabel(l2)
method.visitLocalVariable('this', 'Lnet/minecraftforge/artifactural/gradle/GradleRepositoryAdapter$1$1;', null, l0, l2, 0)
method.visitLocalVariable('componentArtifactMetadata', 'Lorg/gradle/internal/component/model/ComponentArtifactMetadata;', null, l0, l2, 1)
method.visitLocalVariable('moduleSources', 'Lorg/gradle/internal/component/model/ModuleSources;', null, l0, l2, 2)
method.visitLocalVariable('buildableArtifactFileResolveResult', 'Lorg/gradle/internal/resolve/result/BuildableArtifactResolveResult;', null, l0, l2, 3)
method.visitEnd()
}
{
final method = clazz.visitMethod(Opcodes.ACC_PUBLIC, 'resolveArtifacts', '(Lorg/gradle/internal/component/model/ComponentArtifactMetadata;Lorg/gradle/internal/component/model/ConfigurationMetadata;Lorg/gradle/internal/resolve/result/BuildableComponentArtifactsResolveResult;)V', null, new String[] {})
final l0 = new Label()
method.visitLabel(l0)
method.visitVarInsn(Opcodes.ALOAD, 0)
method.visitFieldInsn(Opcodes.GETFIELD, 'net/minecraftforge/artifactural/gradle/GradleRepositoryAdapter$1$1', 'val$delegate', 'Lorg/gradle/api/internal/artifacts/ivyservice/ivyresolve/ModuleComponentRepositoryAccess;')
method.visitVarInsn(Opcodes.ALOAD, 1)
method.visitVarInsn(Opcodes.ALOAD, 2)
method.visitVarInsn(Opcodes.ALOAD, 3)
method.visitMethodInsn(Opcodes.INVOKEINTERFACE, 'org/gradle/api/internal/artifacts/ivyservice/ivyresolve/ModuleComponentRepositoryAccess', 'resolveArtifacts', '(Lorg/gradle/internal/component/model/ComponentArtifactMetadata;Lorg/gradle/internal/component/model/ModuleSources;Lorg/gradle/internal/resolve/result/BuildableComponentArtifactsResolveResult;)V', true)
final l1 = new Label()
method.visitLabel(l1)
method.visitInsn(Opcodes.RETURN)
final l2 = new Label()
method.visitLabel(l2)
method.visitLocalVariable('this', 'Lnet/minecraftforge/artifactural/gradle/GradleRepositoryAdapter$1$1;', null, l0, l2, 0)
method.visitLocalVariable('componentArtifactMetadata', 'Lorg/gradle/internal/component/model/ComponentArtifactMetadata;', null, l0, l2, 1)
method.visitLocalVariable('metadata', 'Lorg/gradle/internal/component/model/ConfigurationMetadata;', null, l0, l2, 2)
method.visitLocalVariable('buildableArtifactFileResolveResult', 'Lorg/gradle/internal/resolve/result/BuildableComponentArtifactsResolveResult;', null, l0, l2, 3)
method.visitEnd()
}
}
file.set(tasks.jar.archiveFile)
}
jar {
from sourceSets.api.output
from sourceSets.shared.output
from sourceSets.gradlecomp.output
finalizedBy('transformJar')
}
sourcesJar {
from sourceSets.api.allSource
from sourceSets.shared.allSource
from sourceSets.gradlecomp.allSource
}
license {
header = file("$rootDir/LICENSE-header.txt")
}
publishing {
publications.create("mavenJava", MavenPublication) {
from components.java
pom {
groupId = project.group
version = project.version
artifactId = project.archivesBaseName
name = project.archivesBaseName
packaging = 'jar'
description = 'A Gradle artifact processing and management tool'
url = 'https://github.com/MinecraftForge/Artifactural/'
scm {
url = 'https://github.com/MinecraftForge/Artifactural/'
connection = 'scm:git:git://github.com/MinecraftForge/Artifactural.git'
developerConnection = 'scm:git:git@github.com:MinecraftForge/Artifactural.git'
}
issueManagement {
system = 'github'
url = 'https://github.com/MinecraftForge/Artifactural/issues'
}
licenses {
license {
name = 'LGPL-2.1'
url = 'https://www.gnu.org/licenses/lgpl-2.1.txt'
distribution = 'repo'
}
}
}
}
repositories {
maven gradleutils.getPublishingForgeMaven()
}
}
|