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
-
12
1
import java.nio.file.Files
13
- import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
2
+ import static java.nio.file.StandardCopyOption.REPLACE_EXISTING
14
3
15
4
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'
36
6
37
7
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"
51
9
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} "
76
12
}
77
13
78
14
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
81
15
pom {
82
16
project {
83
17
groupId " org.p5android"
@@ -96,13 +30,13 @@ task createPom {
96
30
groupId " com.android.support"
97
31
artifactId " support-v4"
98
32
version " ${ supportLibsVersion} "
99
- scope " compile "
33
+ scope " implementation "
100
34
}
101
35
dependency {
102
36
groupId " com.google.android.support"
103
37
artifactId " wearable"
104
38
version " ${ wearVersion} "
105
- scope " compile "
39
+ scope " implementation "
106
40
}
107
41
}
108
42
}
@@ -145,18 +79,34 @@ clean.doFirst {
145
79
delete " ${ coreZipPath} "
146
80
}
147
81
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
+
148
98
build. doLast {
149
99
// Copying core jar as zip inside the mode folder
150
100
Files . copy(file(" ${ buildDir} /libs/core.jar" ). toPath(),
151
- file(" ${ coreZipPath} " ). toPath(), REPLACE_EXISTING );
101
+ file(" ${ coreZipPath} " ). toPath(), REPLACE_EXISTING )
152
102
153
103
// 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 )
162
112
}
0 commit comments