-
-
Notifications
You must be signed in to change notification settings - Fork 23
/
build.gradle
183 lines (154 loc) · 5.91 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
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
181
182
183
import java.nio.file.Paths
import java.util.jar.JarEntry
import java.util.jar.JarFile
apply plugin: 'java-library'
java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
def version = "4.0.0"
def hasProject = file("$project.rootDir/gradle.properties").exists();
repositories {
google()
mavenCentral()
maven {
url 'https://maven.google.com/'
name 'Google'
}
maven { url "https://repo1.maven.org/maven2/" }
maven { url "https://repo.maven.apache.org/maven2/" }
}
if (!project.hasProperty("loadedProjectDeps") && hasProject) {
Properties projectDeps = new Properties()
projectDeps.load(new FileInputStream("$project.rootDir/gradle.properties"))
projectDeps.each { prop ->
project.ext.set(prop.key, prop.value)
}
project.ext.loadedProjectDeps = true
}
if(!hasProject){
project.ext.set("ns_default_bcel_version", "6.10.0");
project.ext.set("ns_default_commons_io_version", "2.6");
project.ext.set("ns_default_spotbugs_version", "3.1.12");
}
// todo: check if still needed
// if(!project.hasProperty("loadedProjectDeps")){
// Properties projectDeps = new Properties()
// projectDeps.load(new FileInputStream("$project.rootDir/gradle.properties"))
// projectDeps.each { prop ->
// project.ext.set(prop.key, prop.value)
// }
// project.ext.loadedProjectDeps = true
// }
project.ext.extractedDependenciesDir = "jar-files"
if (project.hasProperty("jarsOutput")) {
project.ext.extractedDependenciesDir = project.ext.jarsOutput
}
allprojects {
gradle.projectsEvaluated {
tasks.withType(JavaCompile).tap {
configureEach {
options.compilerArgs << "-Xlint:all" << "-Werror"
}
}
}
}
dependencies {
// println "\t ~ [DEBUG][dts-generator] build.gradle - ns_default_bcel_version = ${ns_default_bcel_version}..."
implementation "org.apache.bcel:bcel:${ns_default_bcel_version}"
implementation "commons-io:commons-io:${ns_default_commons_io_version}"
implementation "com.github.spotbugs:spotbugs:${ns_default_spotbugs_version}"
// add your dependency here as the example bellow, make sure you are using testCompileOnly
// testCompileOnly "com.android.support:support-v4:27.0.1"
//AndroidX
// testCompileOnly "androidx.legacy:legacy-support-v4:1.0.0"
// testCompileOnly "androidx.appcompat:appcompat:1.0.0"
// testCompileOnly "com.google.android.material:material:1.0.0"
// def androidXLegacyVersion = "1.0.0"
// def androidXAppCompatVersion = "1.6.1"
// def androidXMaterialVersion = "1.8.0"
// def androidXExifInterfaceVersion = "1.3.7"
// def androidXViewPagerVersion = "1.0.0"
// def androidXFragmentVersion = "1.4.1"
// def androidXTransitionVersion = "1.4.1"
//
// testCompileOnly "androidx.legacy:legacy-support-v4:$androidXLegacyVersion"
// testCompileOnly "androidx.appcompat:appcompat:$androidXAppCompatVersion"
// testCompileOnly "com.google.android.material:material:$androidXMaterialVersion"
// testCompileOnly "androidx.exifinterface:exifinterface:$androidXExifInterfaceVersion"
// testCompileOnly "androidx.viewpager2:viewpager2:$androidXViewPagerVersion"
// testCompileOnly "androidx.fragment:fragment:$androidXFragmentVersion"
// testCompileOnly "androidx.transition:transition:$androidXTransitionVersion"
}
configurations.create("dtsGeneratorImplementation") {
extendsFrom configurations.implementation
setCanBeResolved(true)
}
configurations.create("dtsGeneratorTestCompileOnly") {
extendsFrom configurations.testCompileOnly
setCanBeResolved(true)
}
jar {
//pack jar dependencies into the final jar
from {
configurations.dtsGeneratorImplementation.collect { it.isDirectory() ? it : zipTree(it) }
}
from('src/main/resources') {
include 'generics.txt'
}
//set main class for the jar
manifest {
attributes 'Main-Class': 'com.telerik.Main'
attributes 'Specification-Version': version
attributes 'Manifest-Version': version
}
duplicatesStrategy = 'include'
}
task extractAllJars {
outputs.dir extractedDependenciesDir
doLast {
def iter = configurations.dtsGeneratorTestCompileOnly.resolvedConfiguration.resolvedArtifacts.iterator()
def dependencyCounter = 0
while (iter.hasNext()) {
//declaring variable as specific class for getting code completion in Android Studio
def nextDependency = iter.next()
def outputDir = Paths.get(extractedDependenciesDir, nextDependency.toString()).normalize().toString().replace(':', '_')
explodeAar(nextDependency.file, outputDir)
dependencyCounter++
}
}
}
def explodeAar(File compileDependency, String outputDir) {
if (compileDependency.name.endsWith(".aar")) {
JarFile jar = new JarFile(compileDependency)
Enumeration enumEntries = jar.entries()
while (enumEntries.hasMoreElements()) {
JarEntry file = (JarEntry) enumEntries.nextElement()
if (file.name.endsWith(".jar")) {
def f = new File(outputDir, file.name)
new File(f.parent).mkdirs()
InputStream is = jar.getInputStream(file)
FileOutputStream fos = new FileOutputStream(f)
while (is.available() > 0) {
fos.write(is.read())
}
fos.close()
is.close()
}
if (file.isDirectory()) {
continue
}
}
jar.close()
} else if (compileDependency.name.endsWith(".jar")) {
copy {
from compileDependency.absolutePath
into outputDir
}
}
}
// def buildMetadata = tasks.findByPath(":app:buildMetadata")
// if (buildMetadata != null) {
// processResources.dependsOn(buildMetadata)
// compileJava.dependsOn(buildMetadata)
// }