forked from onepf/OpenIAB
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle
129 lines (112 loc) · 4.25 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
apply plugin: 'com.android.application'
def sep = File.separator
def projectDir = rootProject.projectDir.absolutePath;
def unityRootAbsolutePath = "${projectDir}${sep}unity_plugin${sep}unity_src"
def unitySrcPath = "${unityRootAbsolutePath}${sep}Assets${sep}Plugins${sep}Android"
def outAbsoluteDir = "${project.buildDir.absolutePath}${sep}intermediates${sep}unityPlugin${sep}classes"
def outJarAbsoluteDir = "${project.buildDir.absolutePath}${sep}intermediates${sep}unityPlugin"
def unityPackageAbsolutePath = "${project.buildDir.absolutePath}${sep}outputs"
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
defaultConfig {
minSdkVersion 8
targetSdkVersion 19
versionCode 1
versionName "1.0"
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
jniLibs.srcDirs = ['libs']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
androidTest.setRoot('tests')
}
}
buildTypes {
release {
runProguard false
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile project(path: ':library', configuration: "noFortumoUnity")
}
task buildPlugin(dependsOn: 'assembleRelease') << {
final def unityPath = getUnityExecutablePath()
delete fileTree(dir: outAbsoluteDir, include: "*")
mkdir outAbsoluteDir
mkdir unityPackageAbsolutePath
ant.unzip(src: "..${sep}library${sep}libs${sep}in-app-purchasing-1.0.3.jar", dest: outAbsoluteDir)
ant.unzip(src: "build${sep}intermediates${sep}exploded-aar${sep}OpenIAB" +
"${sep}library${sep}unspecified${sep}noFortumoUnity${sep}classes.jar", dest: outAbsoluteDir)
// Copy compiled unity-plugin java source
copy {
from "${projectDir}${sep}unity_plugin${sep}build${sep}intermediates${sep}classes${sep}release"
into outAbsoluteDir
include '**/*.class'
}
// Copy all aidl from library
copy {
from "${projectDir}${sep}library${sep}src"
into outAbsoluteDir
include '**/*.aidl'
}
// Remove unnecessary classes
delete "${outAbsoluteDir}${sep}org${sep}onepf${sep}oms${sep}appstore${sep}fortumoUtils"
delete fileTree(dir: "${outAbsoluteDir}${sep}org${sep}onepf${sep}oms${sep}appstore", include: "Fortumo*.class")
delete "${outAbsoluteDir}${sep}fortumo_res"
delete "${outAbsoluteDir}${sep}mp"
delete "${outAbsoluteDir}${sep}android"
delete "${outAbsoluteDir}${sep}com${sep}braintree"
delete "${outAbsoluteDir}${sep}com${sep}braintreegateway"
delete "${outAbsoluteDir}${sep}com${sep}skplanet"
delete "${outAbsoluteDir}${sep}com${sep}tmoney"
project.exec {
commandLine 'jar'
args 'cf'
args "${outJarAbsoluteDir}${sep}OpenIAB-plugin.jar"
args '-C'
args outAbsoluteDir
args '.'
}
copy {
from outJarAbsoluteDir
include 'OpenIAB-plugin.jar'
into unitySrcPath
}
println "Unity executable: $unityPath"
println "Unity package source root: $unityRootAbsolutePath"
println "Unity package build: $unityPackageAbsolutePath"
project.exec {
commandLine unityPath
args '-batchMode'
args '-projectPath'
args "${unityRootAbsolutePath}"
args '-exportPackage'
args "Assets${sep}OpenIAB-demo"
args "Assets${sep}Plugins"
args "${unityPackageAbsolutePath}${sep}OpenIAB-plugin.unitypackage"
args '-quit'
}
}
def getUnityExecutablePath() {
if (project.hasProperty('unityExecutable')) {
exePath = project.property('unityExecutable');
} else {
def paths = ['unityWin86Path', 'unityMacPath', 'unityWin64Path',]
for (path in paths) {
if (file(project.property(path)).exists()) {
return project.property(path);
}
}
}
throw new RuntimeException("Unity not found. Please make sure Unity " +
"is installed at default location or provide 'unityExecutable' property.");
}