-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathbuild.gradle
164 lines (146 loc) · 6.16 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
buildscript {
repositories {
google()
jcenter()
}
dependencies {
/**
* Dependencies to support bintray upload
*/
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4'
/**
* Be careful at upgrading to higher version of gradle (e.g., > 3.0):
* Compilation may work but application will have error when executed due to AAPT2 exception.
* Disabling AAPT2 will hide an issue with AAPT2 and may cause to stop unit tests to work.
* Please update only after either the issue is fixed on Android side or fix the bug in the project for AAPT2.
* https://issuetracker.google.com/issues/38454212
* https://github.com/requery/requery/issues/467
*/
classpath 'com.android.tools.build:gradle:3.4.1'
}
}
plugins {
// Google Java Format Plugin:
// 1. Run `gradlew goJF` to format source codes
// 2. Run `gradlew verGJF` to verify code farmat
// 3. More usage information can be found at
// https://github.com/sherter/google-java-format-gradle-plugin
id 'com.github.sherter.google-java-format' version '0.8'
}
subprojects {
repositories {
mavenCentral()
jcenter()
google()
}
apply plugin: 'maven'
apply plugin: 'maven-publish'
apply plugin: 'com.jfrog.bintray'
apply plugin: 'java'
apply plugin: 'com.github.sherter.google-java-format'
// Bintray Configurations:
// 1. Env variable BINTRAY_USER and BINTRAY_API_KEY must be set
// properly in order to enable bintray upload. Information can
// be found in pinned messages in #dcap slack channel.
// 2. Run "gradlew --info bintrayUpload" in project dir to upload
// jar file. For example, to upload amino-run-core.jar, you need to
// run "gradlew --info bintrayUpload" in core project.
// 3. If you modified amino-run-core.jar without bumping up the
// package version, then you need to remind developers to clean
// old versions from gradle cache by running $(rm -rf ~/.gradle/caches).
bintray {
user = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER')
key = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY')
configurations = ['archives']
publications = ['Production']
override = true
pkg {
dryRun = false
publish = true
repo = project.property('bintrayRepo')
name = project.property('bintrayPkgName')
licenses = [project.property('bintrayLicense')]
vcsUrl = project.property('bintrayVcsUrl')
version {
name = project.property('bintrayVersion')
}
}
}
// Maven Configurations
publishing {
publications {
Production(MavenPublication) {
groupId project.property('mavenGroupId')
artifactId project.property('mavenArtifactId')
version project.property('mavenVersion')
pom.withXml {
def dependenciesNode = asNode().appendNode('dependencies')
// Iterate over the implementation dependencies (we don't want the test ones), adding a <dependency> node for each
configurations.implementation.allDependencies.each {
//Ensure dependencies such as fileTree are not included in the pom.
if (it.name != 'unspecified') {
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', it.group)
dependencyNode.appendNode('artifactId', it.name)
dependencyNode.appendNode('version', it.version)
}
}
}
}
}
}
// Common rules for all JavaExec tasks, being added before execution.
tasks.withType(JavaExec).whenTaskAdded {
classpath += sourceSets.main.runtimeClasspath
}
// Added for enforcing Java 1.6 version compatibility.
// Note that this will not result in compilation failure unless JDK 1.6 or less is used.
// GraalVM supports from JDK 1.8; therefore, it doesn't have an effect except IDE inspector
// may show incompatible APIs for higher version than JDK 1.6.
tasks.withType(JavaCompile) {
def javaVersion = JavaVersion.VERSION_1_6
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
options.bootstrapClasspath = files("$System.env.JAVA_HOME/jre/lib/rt.jar")
}
// SourceSet for generated stubs
sourceSets {
stubs
}
// Task for Stub Generation:
// Run `gradlew genStubs` to generate stub files
task genStubs(type: JavaExec) {
main = "amino.run.compiler.StubGenerator"
}
// Configure "stubs" sourceSet compile task, with additional rules.
compileStubsJava {
classpath += sourceSets.main.runtimeClasspath
options.incremental = true
dependsOn genStubs
}
clean {
delete genStubs.outputs.files // Add generated stubs to what the clean task must delete
doLast {
logger.info('Clean will delete ' + clean.targetFiles.asCollection())
}
}
/*
jar
Depends on: classes
Assembles the production JAR file, based on the classes and resources attached to the main
source set.
*/
jar {
// Also include stubs sourceSet classes in the jar file.
from sourceSets.stubs.output.classesDirs
}
googleJavaFormat {
options style: 'AOSP'
exclude '**/*_Stub.java' // Don't reformat autogenerated stubs, otherwise they look out of
// date and get regenerated and reformatted again and again.
}
tasks.googleJavaFormat.dependsOn tasks.withType(AbstractCompile)
check.dependsOn tasks.googleJavaFormat
check.dependsOn tasks.withType(AbstractCompile) // Ensure that all compileTasks are executed, as part of check.
}