Skip to content

Commit c50a822

Browse files
committed
updated build files
1 parent 50bc0cc commit c50a822

File tree

5 files changed

+101
-253
lines changed

5 files changed

+101
-253
lines changed

build.gradle

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,29 @@ apply plugin: 'java'
99
buildscript {
1010
repositories {
1111
google()
12-
jcenter()
12+
jcenter()
1313
}
14-
dependencies {
15-
classpath 'com.android.tools.build:gradle:3.0.1'
16-
classpath group: 'commons-io', name: 'commons-io', version: '2.5'
17-
classpath group: 'org.zeroturnaround', name: 'zt-zip', version: '1.9'
14+
dependencies {
15+
classpath 'com.android.tools.build:gradle:3.5.1'
16+
classpath group: 'commons-io', name: 'commons-io', version: '2.6'
17+
classpath group: 'org.zeroturnaround', name: 'zt-zip', version: '1.13'
1818
}
1919
}
2020

2121
allprojects {
2222
apply plugin: 'java'
2323
apply plugin: 'java-library'
2424

25-
// Versions of all dependencies
25+
// Versions of all dependencies - TODO: read from some properties file...
2626
ext.targetSdkVersion = '26'
2727
ext.supportLibsVersion = '26.0.2'
2828
ext.wearVersion = '2.1.0'
2929
ext.gvrVersion = '1.150.0'
3030
ext.garVersion = '1.2.0'
3131
ext.processingVersion = '3.3.7'
32-
ext.toolingVersion = '4.3'
33-
ext.slf4jVersion = '1.7.10'
34-
ext.gradlewVersion = '4.4.1'
32+
ext.toolingVersion = '5.6.2'
33+
ext.slf4jVersion = '1.7.28'
34+
ext.gradlewVersion = '5.6.2'
3535
ext.toolsLibVersion = '26.0.0-dev'
3636
ext.jdtVersion = '3.11.100'
3737

@@ -78,13 +78,20 @@ allprojects {
7878
repositories {
7979
google()
8080
jcenter()
81+
maven {
82+
// mavenCentral() does not work to download the Gradle releases of gradle-tooling-api, one needs
83+
// to set the artifact url as below to get the latest packages.
84+
// https://mvnrepository.com/artifact/org.gradle/gradle-tooling-api?repo=gradle-libs-releases-local
85+
url "https://repo1.maven.org/maven2"
86+
artifactUrls "https://repo.gradle.org/gradle/libs-releases-local"
87+
}
8188
flatDir dirs: androidPlatformPath
8289
flatDir dirs: androidToolsLibPath
8390
flatDir dirs: "${rootDir}/core/dist"
8491
}
8592

86-
sourceCompatibility = 1.7
87-
targetCompatibility = 1.7
93+
sourceCompatibility = 1.8
94+
targetCompatibility = 1.8
8895
}
8996

9097
clean.doFirst {
@@ -106,10 +113,10 @@ task dist {
106113
delete "${root}/mode/jdimodel.jar"
107114

108115
Files.copy(file("mode/processing-core.zip").toPath(),
109-
file("${root}/processing-core.zip").toPath(), REPLACE_EXISTING);
116+
file("${root}/processing-core.zip").toPath(), REPLACE_EXISTING)
110117

111118
Files.copy(file("mode/mode.properties").toPath(),
112-
file("${root}/mode.properties").toPath(), REPLACE_EXISTING);
119+
file("${root}/mode.properties").toPath(), REPLACE_EXISTING)
113120

114121
FileUtils.copyDirectory(file("mode/languages"),
115122
file("${root}/languages"))
@@ -126,7 +133,7 @@ task dist {
126133
FileUtils.copyDirectory(file("mode/libraries/vr/src"),
127134
file("${root}/libraries/vr/src"))
128135
Files.copy(file("mode/libraries/vr/library.properties").toPath(),
129-
file("${root}/libraries/vr/library.properties").toPath(), REPLACE_EXISTING);
136+
file("${root}/libraries/vr/library.properties").toPath(), REPLACE_EXISTING)
130137

131138
FileUtils.copyDirectory(file("mode/libraries/ar/examples"),
132139
file("${root}/libraries/ar/examples"))
@@ -135,12 +142,12 @@ task dist {
135142
FileUtils.copyDirectory(file("mode/libraries/ar/src"),
136143
file("${root}/libraries/ar/src"))
137144
Files.copy(file("mode/libraries/ar/library.properties").toPath(),
138-
file("${root}/libraries/ar/library.properties").toPath(), REPLACE_EXISTING);
145+
file("${root}/libraries/ar/library.properties").toPath(), REPLACE_EXISTING)
139146

140-
File distFolder = file("dist");
141-
distFolder.mkdirs();
142-
ZipUtil.pack(file("${buildDir}/zip"), new File("dist/AndroidMode.zip"));
147+
File distFolder = file("dist")
148+
distFolder.mkdirs()
149+
ZipUtil.pack(file("${buildDir}/zip"), new File("dist/AndroidMode.zip"))
143150
Files.copy(file("mode/mode.properties").toPath(),
144-
file("dist/AndroidMode.txt").toPath(), REPLACE_EXISTING);
151+
file("dist/AndroidMode.txt").toPath(), REPLACE_EXISTING)
145152
}
146153
}

core/build.gradle

Lines changed: 32 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,17 @@
1-
import com.android.build.gradle.internal.dependency.ExtractAarTransform
2-
import com.android.build.gradle.internal.dependency.AarTransform
3-
import com.android.build.gradle.internal.publishing.AndroidArtifacts
4-
import com.android.build.gradle.internal.publishing.AndroidArtifacts.ArtifactType
5-
import com.google.common.collect.ImmutableList
6-
import org.gradle.api.artifacts.transform.ArtifactTransform
7-
import org.gradle.api.artifacts.type.ArtifactTypeDefinition
8-
import java.util.regex.Pattern
9-
10-
import static org.gradle.api.internal.artifacts.ArtifactAttributes.ARTIFACT_FORMAT
11-
121
import java.nio.file.Files
13-
import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
2+
import static java.nio.file.StandardCopyOption.REPLACE_EXISTING
143

154
apply plugin: 'maven'
16-
17-
/**
18-
* Custom aar configuration needed to use aar files as dependencies in a pure java
19-
* library project, lifted from the following repo:
20-
* https://github.com/nekocode/Gradle-Import-Aar
21-
*/
22-
configurations {
23-
aar {
24-
attributes {
25-
attribute(ARTIFACT_FORMAT, ArtifactTypeDefinition.JAR_TYPE)
26-
}
27-
28-
// Add the aar inner jars to the compileClasspath
29-
sourceSets.main.compileClasspath += it
30-
31-
// Put our custom dependencies onto IDEA's PROVIDED scope
32-
apply plugin: "idea"
33-
idea.module.scopes.PROVIDED.plus += [it]
34-
}
35-
}
5+
apply plugin: 'aar'
366

377
dependencies {
38-
// Transforamtions to extract the classes.jar in the aar package
39-
def explodedAarType = ArtifactType.EXPLODED_AAR.getType()
40-
registerTransform {
41-
from.attribute(ARTIFACT_FORMAT, AndroidArtifacts.TYPE_AAR)
42-
to.attribute(ARTIFACT_FORMAT, explodedAarType)
43-
artifactTransform(ExtractAarTransform)
44-
}
45-
46-
registerTransform {
47-
from.attribute(ARTIFACT_FORMAT, explodedAarType)
48-
to.attribute(ARTIFACT_FORMAT, "classes.jar")
49-
artifactTransform(AarTransform) { params(ArtifactType.JAR) }
50-
}
8+
implementation name: "android"
519

52-
registerTransform {
53-
from.attribute(ARTIFACT_FORMAT, "classes.jar")
54-
to.attribute(ARTIFACT_FORMAT, ArtifactTypeDefinition.JAR_TYPE)
55-
artifactTransform(ClassesJarArtifactTransform)
56-
}
57-
58-
compileOnly name: "android"
59-
60-
aar "com.android.support:support-v4:${supportLibsVersion}"
61-
aar "com.google.android.support:wearable:${wearVersion}"
62-
}
63-
64-
/**
65-
* An ArtifactTransform for renaming the classes.jar
66-
*/
67-
class ClassesJarArtifactTransform extends ArtifactTransform {
68-
@Override
69-
List<File> transform(File file) {
70-
final String[] names = file.getPath().split(Pattern.quote(File.separator))
71-
final String aarName = names[names.length - 4].replace(".aar", "")
72-
final File renamedJar = new File(getOutputDirectory(), aarName + ".jar")
73-
renamedJar << file.bytes
74-
return ImmutableList.of(renamedJar)
75-
}
10+
implementationAar "com.android.support:support-v4:${supportLibsVersion}"
11+
implementationAar "com.google.android.support:wearable:${wearVersion}"
7612
}
7713

7814
task createPom {
79-
// The compile configuration should be replaced by implementation eventually:
80-
// https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration#new_configurations
8115
pom {
8216
project {
8317
groupId "org.p5android"
@@ -96,13 +30,13 @@ task createPom {
9630
groupId "com.android.support"
9731
artifactId "support-v4"
9832
version "${supportLibsVersion}"
99-
scope "compile"
33+
scope "implementation"
10034
}
10135
dependency {
10236
groupId "com.google.android.support"
10337
artifactId "wearable"
10438
version "${wearVersion}"
105-
scope "compile"
39+
scope "implementation"
10640
}
10741
}
10842
}
@@ -145,18 +79,34 @@ clean.doFirst {
14579
delete "${coreZipPath}"
14680
}
14781

82+
compileJava.doFirst {
83+
String[] deps = ["percent.jar",
84+
"recyclerview-v7.jar",
85+
"support-compat.jar",
86+
"support-core-ui.jar",
87+
"support-core-utils.jar",
88+
"support-fragment.jar",
89+
"support-media-compat.jar",
90+
"support-v4.jar",
91+
"wearable.jar"]
92+
for (String fn : deps) {
93+
Files.copy(file("${rootDir}/build/libs/" + fn).toPath(),
94+
file("${rootDir}/mode/mode/" + fn).toPath(), REPLACE_EXISTING)
95+
}
96+
}
97+
14898
build.doLast {
14999
// Copying core jar as zip inside the mode folder
150100
Files.copy(file("${buildDir}/libs/core.jar").toPath(),
151-
file("${coreZipPath}").toPath(), REPLACE_EXISTING);
101+
file("${coreZipPath}").toPath(), REPLACE_EXISTING)
152102

153103
// Copying the files for release on JCentral
154-
File distFolder = file("dist");
155-
distFolder.mkdirs();
156-
Files.copy(file("$buildDir/libs/core.jar").toPath(),
157-
file("dist/processing-core-${modeVersion}.jar").toPath(), REPLACE_EXISTING);
158-
Files.copy(file("$buildDir/libs/core-sources.jar").toPath(),
159-
file("dist/processing-core-${modeVersion}-sources.jar").toPath(), REPLACE_EXISTING);
160-
Files.copy(file("$buildDir/libs/core.jar.MD5").toPath(),
161-
file("dist/processing-core-${modeVersion}.jar.md5").toPath(), REPLACE_EXISTING);
104+
File distFolder = file("dist")
105+
distFolder.mkdirs()
106+
Files.copy(file("${buildDir}/libs/core.jar").toPath(),
107+
file("dist/processing-core-${modeVersion}.jar").toPath(), REPLACE_EXISTING)
108+
Files.copy(file("${buildDir}/libs/core-sources.jar").toPath(),
109+
file("dist/processing-core-${modeVersion}-sources.jar").toPath(), REPLACE_EXISTING)
110+
Files.copy(file("${buildDir}/libs/core.jar.MD5").toPath(),
111+
file("dist/processing-core-${modeVersion}.jar.md5").toPath(), REPLACE_EXISTING)
162112
}

mode/build.gradle

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ dependencies {
1919

2020
compileAndCopy "org.gradle:gradle-tooling-api:${toolingVersion}"
2121
compileAndCopy "org.slf4j:slf4j-api:${slf4jVersion}"
22-
compileAndCopy "org.slf4j:slf4j-simple:${slf4jVersion}"
22+
compileAndCopy "org.slf4j:slf4j-simple:${slf4jVersion}"
2323

2424
compile fileTree(include: ["jdi.jar", "jdimodel.jar"], dir: 'mode')
2525
}
@@ -72,8 +72,14 @@ wrapper.doLast {
7272
clean.doFirst {
7373
delete fileTree("mode") {
7474
include "**/*.jar"
75-
exclude "jdi.jar"
76-
exclude "jdimodel.jar"
75+
exclude "jdi.jar"
76+
exclude "jdimodel.jar"
77+
exclude "istack-commons-runtime.jar"
78+
exclude "javax.activation-api.jar"
79+
exclude "jaxb-api.jar"
80+
exclude "jaxb-jxc.jar"
81+
exclude "jaxb-runtime.jar"
82+
exclude "jaxb-xjc.jar"
7783
}
7884
}
7985

0 commit comments

Comments
 (0)