Skip to content

Commit 3e4afc3

Browse files
committed
update build.gradle to read project.json and exclude devDependencies from being read and built
1 parent e32d9f4 commit 3e4afc3

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

build/project-template-gradle/build.gradle

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
* -PdontRunSbg=[true/false] (default false)
1919
*/
2020

21+
import groovy.json.JsonSlurper //used to parse package.json
22+
2123
buildscript {
2224
repositories {
2325
jcenter()
@@ -41,6 +43,9 @@ def libDir = "$projectDir/../../lib/Android/"
4143
def flavorNames = new ArrayList<String>()
4244
def configDir = file(configurationsDir)
4345

46+
def packageJsonContents = [:]
47+
def excludedDevDependencies = ['**/.bin/**']
48+
4449
def dontRunSbg = project.hasProperty("dontRunSbg");
4550

4651
def asbgProject = project(":asbg")
@@ -92,6 +97,21 @@ def renameResultApks (variant) {
9297
}
9398
}
9499

100+
// gets the devDependencies declared in the package.json and excludes them from the build
101+
task getDevDependencies << {
102+
println "$configStage getDevDependencies"
103+
104+
String content = new File("$rootDir/../../package.json").getText("UTF-8")
105+
def jsonSlurper = new JsonSlurper()
106+
def packageJsonMap = jsonSlurper.parseText(content)
107+
108+
packageJsonContents = packageJsonMap.devDependencies;
109+
110+
packageJsonContents.each { entry ->
111+
excludedDevDependencies.add(entry.key + '/platforms/android/**/*.jar')
112+
}
113+
}
114+
95115
////////////////////////////////////////////////////////////////////////////////////
96116
///////////////////////////// CONFIGURATIONS ///////////////////////////////////////
97117
////////////////////////////////////////////////////////////////////////////////////
@@ -173,7 +193,7 @@ dependencies {
173193
compile fileTree(dir: "$projectDir/libs", include: ["**/*.jar"])
174194

175195
// take all jars within the node_modules dir
176-
compile fileTree(dir: nodeModulesDir, include: ["**/platforms/android/**/*.jar"], exclude: '**/.bin/**')
196+
compile fileTree(dir: nodeModulesDir, include: ["**/platforms/android/**/*.jar"], exclude: excludedDevDependencies)
177197

178198
//when gradle has aar support this will be preferred instead of addAarDependencies
179199
// compile files("$rootDir/libs/aar") {

0 commit comments

Comments
 (0)