diff --git a/android-static-binding-generator/project/build.gradle b/android-static-binding-generator/project/build.gradle index 63352275c..c4f5d04c8 100644 --- a/android-static-binding-generator/project/build.gradle +++ b/android-static-binding-generator/project/build.gradle @@ -14,7 +14,7 @@ def cachedJarsFilePath = "$projectDir/cached.txt" def jsParserP = "$projectDir/parser/js_parser.js" def jsFilesParametersP = "$projectDir/jsFilesParameters.txt" -def webpackWorkersExcludePath = "$projectDir/../../src/main/assets/app/__worker-chunks.json" +def webpackWorkersExcludePath = "$rootDir/app/src/main/assets/app/__worker-chunks.json" def webpackWorkersExcludesList = []; def workersExcludeFile = file(webpackWorkersExcludePath); @@ -40,8 +40,13 @@ if (project.hasProperty("outDir")) { def absoluteJsCodeDir; def jsCodeAbsolutePath; if (!project.hasProperty("test")) { - absoluteJsCodeDir = project.jsCodeDir - jsCodeAbsolutePath = absoluteJsCodeDir.getAbsolutePath() + println project.jsCodeDir.equals(null) + if(project.jsCodeDir.exists()) { + absoluteJsCodeDir = project.jsCodeDir + jsCodeAbsolutePath = absoluteJsCodeDir.getAbsolutePath() + } else { + logger.log(LogLevel.WARN, "The input jsCodeDir: ${jsCodeDir} folder could not be found. Please make sure you've passed the correct folder containing the .js files that need to be parsed."); + } } def utf8 = StandardCharsets.UTF_8 diff --git a/build-artifacts/project-template-gradle/app/build.gradle b/build-artifacts/project-template-gradle/app/build.gradle new file mode 100644 index 000000000..3446d61ab --- /dev/null +++ b/build-artifacts/project-template-gradle/app/build.gradle @@ -0,0 +1,700 @@ +/* +* Script builds apk in release or debug mode +* To run: +* gradle assembleRelease -Prelease (release mode) +* gradle assembleDebug (debug mode -> default) +* Options: +* -Prelease //this flag will run build in release mode +* -PksPath=[path_to_keystore_file] +* -PksPassword=[password_for_keystore_file] +* -Palias=[alias_to_use_from_keystore_file] +* -Ppassword=[password_for_alias] +* +* -PtargetSdk=[target_sdk] +* -PbuildToolsVersion=[build_tools_version] +* -PsupportVersion=[support_version] +* -PcompileSdk=[compile_sdk_version] + +* -PdontRunSbg=[true/false] +*/ + +import groovy.json.JsonSlurper + +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; + +apply plugin: "com.android.application" + +def metadataParams = new LinkedList () +def allJarPaths = new LinkedList () +def configStage = "\tconfig phase: " +def nodeModulesDir = "../../node_modules/" +def dependenciesJson = file("$rootDir/dependencies.json") + +// the build script will not work with previous versions of the CLI (3.1 or earlier) +if (!dependenciesJson.exists()) { + throw new BuildCancelledException(""" +'dependencies.json' file not found. Check whether the NativeScript CLI has prepared the project beforehand, +and that your NativeScript version is 3.3, or a more recent one. To build an android project with the current +version of the {N} CLI install a previous version of the runtime package - 'tns platform add android@3.2'. +""") +} + +project.ext.extractedDependenciesDir = "${project.buildDir}/exploded-dependencies"; +def nativescriptDependencies = new JsonSlurper().parseText(dependenciesJson.text) + +def packageJsonContents = [:] + +def dontRunSbg = project.hasProperty("dontRunSbg"); +def asbgProject = project(":asbg") +asbgProject.ext.outDir = new File("$projectDir", "src/main/java") +asbgProject.ext.jsCodeDir = new File("$projectDir", "src/main/assets/app") + +def computeCompileSdkVersion = { -> project.hasProperty("compileSdk") ? compileSdk : 23 } +def computeTargetSdkVersion = { -> project.hasProperty("targetSdk") ? targetSdk : 23 } +def computeBuildToolsVersion = { -> project.hasProperty("buildToolsVersion") ? buildToolsVersion : "25.0.2" } + +project.ext.selectedBuildType = project.hasProperty("release") ? "release" : "debug" + +def renameResultApks = { variant -> + def name + variant.outputs.each { output -> + def apkDirectory = output.packageApplication.outputFile.parentFile + def abiName = ""; + if (output.getFilter(com.android.build.OutputFile.ABI)) { + abiName = "-" + output.getFilter(com.android.build.OutputFile.ABI); + } + def apkNamePrefix = rootProject.name + "-" + variant.buildType.name + abiName + name = apkNamePrefix + ".apk" + output.packageApplication.outputFile = new File(apkDirectory, name); + } +} + +//////////////////////////////////////////////////////////////////////////////////// +///////////////////////////// CONFIGURATIONS /////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////// + +def applyPluginsIncludeGradleConfigurations = { -> + def taskNames = project.getGradle().startParameter.taskNames + + // don't apply plugin configurations if clean is invoked + if (taskNames && taskNames.size() > 0 && taskNames.getAt(0).equals("clean")) { + return [] + } + + def configurationsDir = new File(projectDir, "build/configurations") + configurationsDir.deleteDir() + + def dimensions = [] + def includes = new ArrayList() + def flavorNumber = 0 + + nativescriptDependencies.each { dep -> + def androidDir = file("$rootDir/${dep.directory}/platforms/android") + if (!androidDir.exists()) { + return + } + def includeGradleFile = new File(androidDir, "include.gradle") + + def packageJsonPath = file("$rootDir/${dep.directory}/package.json") + def packageJson = new JsonSlurper().parseText(packageJsonPath.text) + def pluginName = packageJson.name + def dimensionName = sanitizeDimensionName(pluginName) + + dimensions.add(dimensionName) + def flavor = "F${flavorNumber++}" + + def destinationDir = file("${configurationsDir}/${pluginName}/") + def destinationIncludeGradleFile = file("${configurationsDir}/${pluginName}/include.gradle") + + Files.createDirectories(Paths.get(destinationDir.getAbsolutePath())) + + if (includeGradleFile.exists()) { + println "\t + add include.gradle from ${includeGradleFile}" + destinationIncludeGradleFile.text = modifyProductFlavorInContent(includeGradleFile.text, dimensionName, flavor) + } else { + println "\t + creating include.gradle for plugin ${file(dep.directory)}" + destinationIncludeGradleFile.text = createProductFlavorsContent(flavor, dimensionName) + } + + includes.add(destinationIncludeGradleFile.getAbsolutePath()); + + copyAndRenamePluginDirToFlavorName(androidDir, flavor); + } + + includes.each { + println "\t + applying plugin configuration from ${it}" + apply from: it + } + + return dimensions +} + +def applyAppGradleConfiguration = { -> + def pathToAppGradle = "$rootDir/../../app/App_Resources/Android/app.gradle" + def appGradle = file(pathToAppGradle) + if (appGradle.exists()) { + println "\t + applying user-defined configuration from ${appGradle}" + apply from: pathToAppGradle + } +} + +android { + compileSdkVersion computeCompileSdkVersion() + buildToolsVersion computeBuildToolsVersion() + + defaultConfig { + minSdkVersion 17 + targetSdkVersion computeTargetSdkVersion() + ndk { + abiFilters "armeabi-v7a", "x86" + } + } + + sourceSets.main { + jniLibs.srcDir "$projectDir/libs/jni" + } + + signingConfigs { + release { + if (project.hasProperty("release")) { + if (project.hasProperty("ksPath") && + project.hasProperty("ksPassword") && + project.hasProperty("alias") && + project.hasProperty("password")) { + + storeFile file(ksPath) + storePassword ksPassword + keyAlias alias + keyPassword password + } + } + } + } + buildTypes { + release { + signingConfig signingConfigs.release + } + } + + applicationVariants.all { variant -> + renameResultApks(variant) + } + + def dimensions = applyPluginsIncludeGradleConfigurations() + + flavorDimensions(*dimensions) + + applyAppGradleConfiguration() +} + +def localRuntimeExists = file("$projectDir/libs/runtime-libs/nativescript-regular.aar").exists() || file("$projectDir/libs/runtime-libs/nativescript-optimized.aar").exists() + +repositories { + + // used for local *.AAR files + def pluginDependencies = nativescriptDependencies.collect { "$rootDir/${it.directory}/platforms/android" } + if(localRuntimeExists) { + pluginDependencies.add("libs/runtime-libs") + } + + flatDir { + dirs pluginDependencies + } +} + +dependencies { + def supportVer = "22.2.0" + if (project.hasProperty("supportVersion")) { + supportVer = supportVersion + } + + compile "com.android.support:support-v4:$supportVer" + compile "com.android.support:appcompat-v7:$supportVer" + debugCompile "com.android.support:design:$supportVer" +} + +//////////////////////////////////////////////////////////////////////////////////// +///////////////////////////// CONFIGURATION PHASE ////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////// + +task addNativeScriptRuntimePackageDependency { + def useV8Symbols = nativescriptDependencies.any { + def packageJsonPath = file("$rootDir/${it.directory}/package.json"); + def packageJson = new JsonSlurper().parseText(packageJsonPath.text); + return packageJson.nativescript.useV8Symbols; + } + + if(localRuntimeExists) { + def runtime = useV8Symbols ? "nativescript-regular" : "nativescript-optimized"; + println "\t + adding nativescript runtime package dependency: $runtime" + project.dependencies.add("compile", [name: runtime, ext: "aar"]) + } +} + +task addDependenciesFromNativeScriptPlugins { + nativescriptDependencies.each { dep -> + def aarFiles = fileTree(dir: file("$rootDir/${dep.directory}/platforms/android"), include: ["**/*.aar"]) + aarFiles.each { aarFile -> + def length = aarFile.name.length() - 4 + def fileName = aarFile.name[0.. + println "\t + adding jar plugin dependency: " + jarFile.getAbsolutePath() + } + + project.dependencies.add("compile", jarFiles) + } +} + +static def updateProductFlavorsContent(flavor, dimensionName, oldContent) { + def endIndex = oldContent.length() - 1; + def index = 0; + def newContent = ""; + def level = -1; + def dimensionFound = false; + + while(index <= endIndex) { + if (level == 0 && (oldContent[index] == '"' || oldContent[index] == "'")) { + def closingQuotes = oldContent.indexOf('"', index + 1); + if (closingQuotes == -1) { + closingQuotes = oldContent.indexOf("'", index + 1); + } + + index = closingQuotes + 1; + newContent += "\"${flavor}\""; + continue; + } + + if (oldContent[index] == "{") { + level++; + } + + if (oldContent[index] == "}") { + level--; + } + + if (level > 0) { + if (!dimensionFound && oldContent.indexOf("dimension", index) == index) { + newContent += "dimension \"${dimensionName}\""; + dimensionFound = true; + index += "dimension ".length(); + def openingQuoutes = oldContent.indexOf('"', index); + if (openingQuoutes == -1) { + openingQuoutes = oldContent.indexOf("'", index); + } + + def closingQuotes = oldContent.indexOf('"', openingQuoutes + 1); + if (closingQuotes == -1) { + closingQuotes = oldContent.indexOf("'", openingQuoutes + 1); + } + + index = closingQuotes + 1; + } + } + + newContent += oldContent[index]; + + index++; + } + + return newContent; +} + +static def createProductFlavorsContent(flavor, dimensionName, includeAndroidContent = true) { + if (includeAndroidContent) + { + def content = """ +android { + productFlavors { + "${flavor}" { + dimension "${dimensionName}" + } + } +} +""" + return content; + } + else + { + def content = """ + productFlavors { + "${flavor}" { + dimension "${dimensionName}" + } + } +""" + return content; + } +} + +static def sanitizeDimensionName(str) { + return str.replaceAll(/\W/, "") +} + +static def modifyProductFlavorInContent(content, dimension, flavor) { + def indexStart = content.indexOf("productFlavors"); + def index = indexStart + "productFlavors".length(); + def indexEnd = -1; + def nestedOpenBracketsCount = 0; + + while (index < content.length()) + { + // print content[index]; + if (content[index] == "}") + { + nestedOpenBracketsCount--; + + if (nestedOpenBracketsCount == 0) + { + indexEnd = index; + break; + } + } + else if (content[index] == "{") + { + nestedOpenBracketsCount++; + } + + index++; + } + + if (indexEnd != -1) + { + // full content of productFlavors { ... } -> the substring is parenthesis to parenthesis -> { ... } + def oldProductFlavorsText = content.substring(indexStart, indexEnd + 1); + + def newProductFlavorsContent = updateProductFlavorsContent(flavor, dimension, oldProductFlavorsText); + + return content.replace(oldProductFlavorsText, newProductFlavorsContent); + } + else + { + def androidContentExists = content.indexOf("android {") != -1; + def newProductFlavorsContent = createProductFlavorsContent(flavor, dimension, !androidContentExists); + + if (androidContentExists) + { + return content.replace("android {", "android { ${newProductFlavorsContent}"); + } + else + { + return "${newProductFlavorsContent} \t ${content}" + } + } +} + +def copyFolder(source, destination) { + if (source.isDirectory()) { + Files.createDirectories(destination.toPath()); + + def sourceFiles = source.list(); + + sourceFiles.each { file -> + def srcFile = new File(source, file); + def destFile = new File(destination, file); + + //Recursive function call + copyFolder(srcFile, destFile); + } + } + else { + // Copy the file content from one place to another + def fileName = source.getName() + def extension = fileName.lastIndexOf(".") != -1 && fileName.lastIndexOf(".") != 0 ? fileName.substring(fileName.lastIndexOf(".") + 1) : ""; + // exclude aars from package, as we've already included it in the compile dependencies, and don't want it taking up space + if (extension == "aar") { + return + } + + Files.copy(source.toPath(), destination.toPath(), java.nio.file.StandardCopyOption.REPLACE_EXISTING); + } +} + +def copyAndRenamePluginDirToFlavorName(directory, flavor) { + def targetDir = file("src/${flavor}") + + copyFolder(directory, targetDir) +} + +task ensureMetadataOutDir { + doLast { + def outputDir = file("$projectDir/metadata/output/assets/metadata") + outputDir.mkdirs() + } +} + +//////////////////////////////////////////////////////////////////////////////////// +///////////////////////////// EXECUTUION PHASE ///////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////// + +tasks.whenTaskAdded({ org.gradle.api.DefaultTask currentTask -> + if(currentTask =~ /generate.+BuildConfig/ ) { + currentTask.finalizedBy(extractAllJars) + extractAllJars.finalizedBy(collectAllJars) + collectAllJars.finalizedBy(setProperties) + } + if(currentTask =~ /compile.+JavaWithJavac/ ) { + currentTask.dependsOn(":asbg:generateBindings") + currentTask.finalizedBy(ensureMetadataOutDir) + ensureMetadataOutDir.finalizedBy(buildMetadata) + } + if(currentTask.equals("assembleDebug") || currentTask.equals("assembleRelease")) { + currentTask.finalizedBy("validateAppIdMatch"); + } +}) + +def explodeAar (File compileDependency, String outputDir) { + if(compileDependency.name.endsWith(".aar")) { + JarFile jar = new JarFile(compileDependency) + Enumeration enumEntries = jar.entries() + while (enumEntries.hasMoreElements()) { + JarEntry file = (JarEntry) enumEntries.nextElement(); + if(file.name.endsWith(".jar")) { + def f = new File(outputDir , file.name); + new File(f.parent).mkdirs(); + InputStream is = jar.getInputStream(file); + FileOutputStream fos = new FileOutputStream(f); + while (is.available() > 0) { + fos.write(is.read()) + } + fos.close() + is.close() + } + if (file.isDirectory()) { + continue + } + } + jar.close() + } + else if(compileDependency.name.endsWith(".jar")) { + copy { + from compileDependency.absolutePath + into outputDir + } + } +} + +task extractAllJars { + + outputs.dir extractedDependenciesDir + + doLast { + def iter = configurations.compile.resolvedConfiguration.resolvedArtifacts.iterator() + def dependencyCounter = 0; + while(iter.hasNext()) { + //declaring variable as specific class for getting code completion in Android Studio + org.gradle.api.internal.artifacts.DefaultResolvedArtifact nextDependency = iter.next(); + + def outputDir = java.nio.file.Paths.get(extractedDependenciesDir, ""+dependencyCounter).normalize().toString(); + explodeAar(nextDependency.file, outputDir) + dependencyCounter++; + } + } +} + +task collectAllJars { + description "gathers all paths to jar dependencies before building metadata with them" + + def sdkPath = android.sdkDirectory.getAbsolutePath(); + def androidJar = sdkPath + "/platforms/" + android.compileSdkVersion + "/android.jar" + + doFirst { + configurations.compile.each { File dependencyFile -> + logger.info("Task: collectAllJars: dependency file: " + dependencyFile.getAbsolutePath()) + allJarPaths.add(dependencyFile.getAbsolutePath()) + } + + allJarPaths.add(androidJar); + + def ft = fileTree(dir: extractedDependenciesDir, include: "**/*.jar") + ft.each { currentJarFile -> + allJarPaths.add(currentJarFile.getAbsolutePath()) + } + + metadataParams.add("metadata-generator.jar"); + metadataParams.add("$projectDir/metadata/output/assets/metadata"); + def jars = new LinkedList() + for (def i = 0; i < allJarPaths.size(); i++) { + metadataParams.add(allJarPaths.get(i)); + def f = new File(allJarPaths.get(i)) + if (f.getName().endsWith(".jar")) { + jars.add(f) + } + } + + asbgProject.ext.jarFiles = jars + } +} + +task buildMetadata (type: JavaExec) { + description "builds metadata with provided jar dependencies" + + inputs.files(allJarPaths) + inputs.dir("$buildDir/intermediates/classes") + + outputs.files("metadata/output/assets/metadata/treeNodeStream.dat", "metadata/output/assets/metadata/treeStringsStream.dat", "metadata/output/assets/metadata/treeValueStream.dat") + + doFirst { + // get compiled classes to pass to metadata generator + // these need to be called after the classes have compiled + def classesDir = "$buildDir/intermediates/classes" + + def classesSubDirs = new File(classesDir).listFiles() + def selectedBuildType = project.ext.selectedBuildType + + for (File subDir: classesSubDirs) { + if (!subDir.getName().equals(selectedBuildType)) { + def subDirBuildType = new File(subDir, selectedBuildType) + if (subDirBuildType.exists()) { + metadataParams.add(subDirBuildType.getAbsolutePath()); + } + } + } + + def classesDirBuildType = new File(classesDir, selectedBuildType) + if (classesDirBuildType.exists()) { + metadataParams.add(classesDirBuildType.getAbsolutePath()) + } + + workingDir "$rootDir/build-tools" + main "-jar" + + logger.info("Task buildMetadata: Call metadata-generator.jar with arguments: " + metadataParams.toString().replaceAll(',', '')) + args metadataParams.toArray() + } + + doLast { + copy { + from "$projectDir/metadata/output/assets/metadata" + into "$projectDir/src/main/assets/metadata" + } + } +} + +task generateTypescriptDefinitions (type: JavaExec) { + def paramz = new ArrayList(); + def includeDirs = ["com.android.support", "/platforms/" + android.compileSdkVersion] + + doFirst { + delete "$rootDir/build-tools/typings" + + workingDir "$rootDir/build-tools" + + main "-jar" + + paramz.add("dts-generator.jar"); + paramz.add("-input"); + + for (String jarPath: project.jarFiles) { + // don't generate typings for runtime jars and classes + if (shouldIncludeDirForTypings(jarPath, includeDirs)) { + paramz.add(jarPath); + } + } + + paramz.add("-output"); + paramz.add("typings"); + + logger.info("Task generateTypescriptDefinitions: Call dts-generator.jar with arguments: " + paramz.toString().replaceAll(',', '')) + args paramz.toArray(); + } +} + +generateTypescriptDefinitions.onlyIf { + project.hasProperty("generateTypings") && Boolean.parseBoolean(project.generateTypings) +} + +static def shouldIncludeDirForTypings(path, includeDirs) { + for (String p: includeDirs) { + if (path.indexOf(p) > -1) { + return true; + } + } + + return false; +} + +task copyTypings { + doLast { + println "Copied generated typings to application root level. Make sure to import android.d.ts in reference.d.ts" + + copy { + from "$rootDir/build-tools/typings" + into "$rootDir/../../" + } + } +} + +copyTypings.onlyIf { generateTypescriptDefinitions.didWork } + +task validateAppIdMatch { + doLast { + def packageJsonFile = new File("$rootDir/../../package.json"); + def lineSeparator = System.getProperty("line.separator"); + + if (packageJsonFile.exists() && !project.hasProperty("release")) { + String content = packageJsonFile.getText("UTF-8") + def jsonSlurper = new JsonSlurper() + def packageJsonMap = jsonSlurper.parseText(content) + + if (packageJsonMap.nativescript.id != android.defaultConfig.applicationId) { + def errorMessage = "${lineSeparator}WARNING: The Application identifier is different from the one inside 'package.json' file.$lineSeparator" + + "NativeScript CLI might not work properly.$lineSeparator" + + "Update the application identifier in package.json and app.gradle so that they match."; + logger.error(errorMessage); + } + } + } +} + +//////////////////////////////////////////////////////////////////////////////////// +////////////////////////////// OPTIONAL TASKS ////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////// + +task setProperties { + project.ext.jarFiles = [] + doLast { + def list = []; + allJarPaths.each({f -> + if(f.endsWith(".jar")) { + list.add(f); + } + }) + project.jarFiles = list; + } +} + +//////// custom clean /////////// +task deleteMetadata (type: Delete){ + delete "$projectDir/metadata/output", "$projectDir/src/main/assets/metadata" +} + +task deleteFlavors (type: Delete){ + doLast { + def srcDir = new File("$projectDir/src") + srcDir.listFiles().each({ f -> + def dirName = f.getName() + if (dirName != "main" && + dirName != "debug" && + dirName != "release") { + delete f + } + }) + } +} + +task deleteGeneratedBindings(type: Delete) { + delete "$projectDir/src/main/java/com/tns/gen" +} + +deleteMetadata.dependsOn(":asbg:clean") +deleteFlavors.dependsOn(deleteMetadata) +deleteGeneratedBindings.dependsOn(deleteFlavors) +clean.dependsOn(deleteGeneratedBindings) diff --git a/build-artifacts/project-template-gradle/src/debug/res/layout/error_activity.xml b/build-artifacts/project-template-gradle/app/src/debug/res/layout/error_activity.xml similarity index 100% rename from build-artifacts/project-template-gradle/src/debug/res/layout/error_activity.xml rename to build-artifacts/project-template-gradle/app/src/debug/res/layout/error_activity.xml diff --git a/build-artifacts/project-template-gradle/src/debug/res/layout/exception_tab.xml b/build-artifacts/project-template-gradle/app/src/debug/res/layout/exception_tab.xml similarity index 100% rename from build-artifacts/project-template-gradle/src/debug/res/layout/exception_tab.xml rename to build-artifacts/project-template-gradle/app/src/debug/res/layout/exception_tab.xml diff --git a/build-artifacts/project-template-gradle/src/debug/res/layout/logcat_tab.xml b/build-artifacts/project-template-gradle/app/src/debug/res/layout/logcat_tab.xml similarity index 100% rename from build-artifacts/project-template-gradle/src/debug/res/layout/logcat_tab.xml rename to build-artifacts/project-template-gradle/app/src/debug/res/layout/logcat_tab.xml diff --git a/build-artifacts/project-template-gradle/src/debug/res/values/colors.xml b/build-artifacts/project-template-gradle/app/src/debug/res/values/colors.xml similarity index 100% rename from build-artifacts/project-template-gradle/src/debug/res/values/colors.xml rename to build-artifacts/project-template-gradle/app/src/debug/res/values/colors.xml diff --git a/build-artifacts/project-template-gradle/src/main/AndroidManifest.xml b/build-artifacts/project-template-gradle/app/src/main/AndroidManifest.xml similarity index 100% rename from build-artifacts/project-template-gradle/src/main/AndroidManifest.xml rename to build-artifacts/project-template-gradle/app/src/main/AndroidManifest.xml diff --git a/build-artifacts/project-template-gradle/src/main/res/values-v21/colors.xml b/build-artifacts/project-template-gradle/app/src/main/res/values-v21/colors.xml similarity index 100% rename from build-artifacts/project-template-gradle/src/main/res/values-v21/colors.xml rename to build-artifacts/project-template-gradle/app/src/main/res/values-v21/colors.xml diff --git a/build-artifacts/project-template-gradle/src/main/res/values-v21/styles.xml b/build-artifacts/project-template-gradle/app/src/main/res/values-v21/styles.xml similarity index 100% rename from build-artifacts/project-template-gradle/src/main/res/values-v21/styles.xml rename to build-artifacts/project-template-gradle/app/src/main/res/values-v21/styles.xml diff --git a/build-artifacts/project-template-gradle/src/main/res/values/colors.xml b/build-artifacts/project-template-gradle/app/src/main/res/values/colors.xml similarity index 100% rename from build-artifacts/project-template-gradle/src/main/res/values/colors.xml rename to build-artifacts/project-template-gradle/app/src/main/res/values/colors.xml diff --git a/build-artifacts/project-template-gradle/src/main/res/values/errorstyles.xml b/build-artifacts/project-template-gradle/app/src/main/res/values/errorstyles.xml similarity index 100% rename from build-artifacts/project-template-gradle/src/main/res/values/errorstyles.xml rename to build-artifacts/project-template-gradle/app/src/main/res/values/errorstyles.xml diff --git a/build-artifacts/project-template-gradle/src/main/res/values/strings.xml b/build-artifacts/project-template-gradle/app/src/main/res/values/strings.xml similarity index 100% rename from build-artifacts/project-template-gradle/src/main/res/values/strings.xml rename to build-artifacts/project-template-gradle/app/src/main/res/values/strings.xml diff --git a/build-artifacts/project-template-gradle/src/main/res/values/styles.xml b/build-artifacts/project-template-gradle/app/src/main/res/values/styles.xml similarity index 100% rename from build-artifacts/project-template-gradle/src/main/res/values/styles.xml rename to build-artifacts/project-template-gradle/app/src/main/res/values/styles.xml diff --git a/build-artifacts/project-template-gradle/build-tools/check-v8-dependants.js b/build-artifacts/project-template-gradle/build-tools/check-v8-dependants.js deleted file mode 100644 index 75b045209..000000000 --- a/build-artifacts/project-template-gradle/build-tools/check-v8-dependants.js +++ /dev/null @@ -1,39 +0,0 @@ -'use strict'; - -let args = process.argv; -let dependencies = JSON.parse(args[2]); -let platformsDir = args[3]; - -const path = require("path"), - fs = require("fs"); - -if (dependencies) { - let platformDir = path.join(platformsDir, "android"); - let buildDir = path.join(platformDir, "build-tools"); - let useV8File = path.join(buildDir, 'useV8'); - - try { - fs.unlinkSync(useV8File); - } catch (e) { - - } - - let useV8Symbols = false; - - for (let dependencyName in dependencies) { - let dependency = dependencies[dependencyName]; - - let isPlugin = !!dependency.nativescript; - if (isPlugin) { - let consumesV8Symbols = !!dependency.nativescript.useV8symbols; - if (consumesV8Symbols) { - useV8Symbols = true; - break; - } - } - } - - if (useV8Symbols) { - fs.writeFileSync(useV8File, "1"); - } -} \ No newline at end of file diff --git a/build-artifacts/project-template-gradle/build-tools/runtime-modules/binding-generator/build.gradle b/build-artifacts/project-template-gradle/build-tools/runtime-modules/binding-generator/build.gradle deleted file mode 100644 index 39fc2fb4f..000000000 --- a/build-artifacts/project-template-gradle/build-tools/runtime-modules/binding-generator/build.gradle +++ /dev/null @@ -1,2 +0,0 @@ -configurations.maybeCreate("default") -artifacts.add("default", file('../../../libs/runtime-libs/binding-generator.aar')) \ No newline at end of file diff --git a/build-artifacts/project-template-gradle/build.gradle b/build-artifacts/project-template-gradle/build.gradle index cc0f394f8..f6050738b 100644 --- a/build-artifacts/project-template-gradle/build.gradle +++ b/build-artifacts/project-template-gradle/build.gradle @@ -1,697 +1,23 @@ -/* -* Script builds apk in release or debug mode -* To run: -* gradle buildapk -Prelease (release mode) -* gradle buildapk (debug mode -> default) -* Options: -* -Prelease //this flag will run build in release mode -* -PksPath=[path_to_keystore_file] -* -PksPassword=[password_for_keystore_file] -* -Palias=[alias_to_use_from_keystore_file] -* -Ppassword=[password_for_alias] -* -* -PtargetSdk=[target_sdk] -* -PbuildToolsVersion=[build_tools_version] -* -PsupportVersion=[support_version] -* -PcompileSdk=[compile_sdk_version] - -* -PdontRunSbg=[true/false] -*/ - -import groovy.json.JsonSlurper - -import java.nio.file.Files; -import java.nio.file.Paths; +// Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { + repositories { + google() jcenter() } - - dependencies { - classpath "com.android.tools.build:gradle:2.2.3" - } -} - -apply plugin: "com.android.application" - -def metadataParams = new LinkedList () -def allJarPaths = new LinkedList () -def configStage = "\tconfig phase: " -def nodeModulesDir = "../../node_modules/" -def dependenciesJson = file("dependencies.json") - -// the build script will not work with previous versions of the CLI (3.1 or earlier) -if (!dependenciesJson.exists()) { - throw new BuildCancelledException(""" -'dependencies.json' file not found. Check whether the NativeScript CLI has prepared the project beforehand, -and that your NativeScript version is 3.3, or a more recent one. To build an android project with the current -version of the {N} CLI install a previous version of the runtime package - 'tns platform add android@3.2'. -""") -} - -def nativescriptDependencies = new JsonSlurper().parseText(dependenciesJson.text) - -def packageJsonContents = [:] - -def dontRunSbg = project.hasProperty("dontRunSbg"); -def asbgProject = project(":asbg") -asbgProject.ext.outDir = new File("$projectDir", "src/main/java") -asbgProject.ext.jsCodeDir = new File("$projectDir", "src/main/assets/app") - -def computeCompileSdkVersion = { -> project.hasProperty("compileSdk") ? compileSdk : 23 } -def computeTargetSdkVersion = { -> project.hasProperty("targetSdk") ? targetSdk : 23 } -def computeBuildToolsVersion = { -> project.hasProperty("buildToolsVersion") ? buildToolsVersion : "25.0.2" } - -project.ext.selectedBuildType = project.hasProperty("release") ? "release" : "debug" - -def renameResultApks = { variant -> - def name - variant.outputs.each { output -> - def apkDirectory = output.packageApplication.outputFile.parentFile - def abiName = ""; - if (output.getFilter(com.android.build.OutputFile.ABI)) { - abiName = "-" + output.getFilter(com.android.build.OutputFile.ABI); - } - def apkNamePrefix = rootProject.name + "-" + variant.buildType.name + abiName - name = apkNamePrefix + ".apk" - output.packageApplication.outputFile = new File(apkDirectory, name); - } -} - -//////////////////////////////////////////////////////////////////////////////////// -///////////////////////////// CONFIGURATIONS /////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////// - -def applyPluginsIncludeGradleConfigurations = { -> - def taskNames = project.getGradle().startParameter.taskNames - - // don't apply plugin configurations if clean is invoked - if (taskNames && taskNames.size() > 0 && taskNames.getAt(0).equals("clean")) { - return [] - } - - def configurationsDir = new File(projectDir, "build/configurations") - configurationsDir.deleteDir() - - def dimensions = [] - def includes = new ArrayList() - def flavorNumber = 0 - - nativescriptDependencies.each { dep -> - def androidDir = file("${dep.directory}/platforms/android") - if (!androidDir.exists()) { - return - } - - def packageJsonPath = file("${dep.directory}/package.json") - def packageJson = new JsonSlurper().parseText(packageJsonPath.text) - def pluginName = packageJson.name - def dimensionName = sanitizeDimensionName(pluginName) - - dimensions.add(dimensionName) - def flavor = "F${flavorNumber++}" - - def includeGradleFile = new File(androidDir, "include.gradle") - def destinationDir = file("${configurationsDir}/${pluginName}/") - def destinationIncludeGradleFile = file("${configurationsDir}/${pluginName}/include.gradle") - - Files.createDirectories(Paths.get(destinationDir.getAbsolutePath())) - - if (includeGradleFile.exists()) { - println "\t + add include.gradle from ${includeGradleFile}" - destinationIncludeGradleFile.text = modifyProductFlavorInContent(includeGradleFile.text, dimensionName, flavor) - } else { - println "\t + creating include.gradle for plugin ${file(dep.directory)}" - destinationIncludeGradleFile.text = createProductFlavorsContent(flavor, dimensionName) - } - - includes.add(destinationIncludeGradleFile.getAbsolutePath()); - - copyAndRenamePluginDirToFlavorName(androidDir, flavor); - } - - includes.each { - println "\t + applying plugin configuration from ${it}" - apply from: it - } - - return dimensions -} - -def applyAppGradleConfiguration = { -> - def pathToAppGradle = "$projectDir/../../app/App_Resources/Android/app.gradle" - def appGradle = file(pathToAppGradle) - if (appGradle.exists()) { - println "\t + applying user-defined configuration from ${appGradle}" - apply from: pathToAppGradle - } -} - -android { - compileSdkVersion computeCompileSdkVersion() - buildToolsVersion computeBuildToolsVersion() - - defaultConfig { - minSdkVersion 17 - targetSdkVersion computeTargetSdkVersion() - ndk { - abiFilters "armeabi-v7a", "x86" - } - } - - sourceSets.main { - jniLibs.srcDir "$projectDir/libs/jni" - } - - signingConfigs { - release { - if (project.hasProperty("release")) { - if (project.hasProperty("ksPath") && - project.hasProperty("ksPassword") && - project.hasProperty("alias") && - project.hasProperty("password")) { - - storeFile file(ksPath) - storePassword ksPassword - keyAlias alias - keyPassword password - } - } - } - } - buildTypes { - release { - signingConfig signingConfigs.release - } + dependencies { + classpath 'com.android.tools.build:gradle:2.3.3' } - - applicationVariants.all { variant -> - renameResultApks(variant) - } - - applicationVariants.all { variant -> - def variantName = variant.name.capitalize() - def compileSourcesTaskName = "compile${variantName}Sources" - def compileSourcesTask = project.tasks.findByName(compileSourcesTaskName) - - def generateBuildConfigTask = variant.generateBuildConfig; - generateBuildConfigTask.finalizedBy(collectAllJars) - if(!dontRunSbg) { - collectAllJars.finalizedBy(setProperties) - } - - compileSourcesTask.finalizedBy(buildMetadata) - - // forces packaging of resources and assets AFTER producing metadata - // Reference: https://github.com/NativeScript/android-runtime/issues/785 - - // Ensure metadata has been built and copied in assets before packaging - variant.outputs.each { output -> - def abiName = ""; - if (output.getFilter(com.android.build.OutputFile.ABI)) { - abiName = output.getFilter(com.android.build.OutputFile.ABI) - def packageTask = project.tasks.findByName("package${output.name}") - if (packageTask) { - packageTask.dependsOn(buildMetadata) - } - } - } - - // Compile the Java sources AFTER the Java code-generation step is done - def compileTask = project.tasks.findByName("compile${variantName}JavaWithJavac") - if (compileTask) { - compileTask.dependsOn("asbg:generateBindings") - } - } - - def dimensions = applyPluginsIncludeGradleConfigurations() - - flavorDimensions(*dimensions) - - applyAppGradleConfiguration() } -repositories { - jcenter() - maven { url 'https://maven.google.com' } - - // used for local *.AAR files - def pluginDependencies = nativescriptDependencies.collect { "${it.directory}/platforms/android" } - pluginDependencies.add("libs/runtime-libs") - - flatDir { - dirs pluginDependencies - } -} - -dependencies { - def supportVer = "22.2.0"; - if (project.hasProperty("supportVersion")) { - supportVer = supportVersion - } - - compile "com.android.support:support-v4:$supportVer" - compile "com.android.support:appcompat-v7:$supportVer" - debugCompile "com.android.support:design:$supportVer" - - // take all jars within the libs dir - compile fileTree(dir: "$projectDir/libs", include: ["**/*.jar"]) -} - -//////////////////////////////////////////////////////////////////////////////////// -///////////////////////////// CONFIGURATION PHASE ////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////// - -task addNativeScriptRuntimePackageDependency { - def useV8Symbols = nativescriptDependencies.any { - def packageJsonPath = file("${it.directory}/package.json"); - def packageJson = new JsonSlurper().parseText(packageJsonPath.text); - return packageJson.nativescript.useV8Symbols; - } - - def runtime = useV8Symbols ? "nativescript-regular" : "nativescript-optimized"; - println "\t + adding nativescript runtime package dependency: $runtime" - - project.dependencies.add("compile", [name: runtime, ext: "aar"]) -} - -task addDependenciesFromNativeScriptPlugins { - nativescriptDependencies.each { dep -> - def aarFiles = fileTree(dir: file("${dep.directory}/platforms/android"), include: ["**/*.aar"]) - aarFiles.each { aarFile -> - def length = aarFile.name.length() - 4 - def fileName = aarFile.name[0.. - println "\t + adding jar plugin dependency: " + jarFile.getAbsolutePath() - } - - project.dependencies.add("compile", jarFiles) - } -} - -static def updateProductFlavorsContent(flavor, dimensionName, oldContent) { - def endIndex = oldContent.length() - 1; - def index = 0; - def newContent = ""; - def level = -1; - def dimensionFound = false; - - while(index <= endIndex) { - if (level == 0 && (oldContent[index] == '"' || oldContent[index] == "'")) { - def closingQuotes = oldContent.indexOf('"', index + 1); - if (closingQuotes == -1) { - closingQuotes = oldContent.indexOf("'", index + 1); - } - - index = closingQuotes + 1; - newContent += "\"${flavor}\""; - continue; - } - - if (oldContent[index] == "{") { - level++; - } - - if (oldContent[index] == "}") { - level--; - } - - if (level > 0) { - if (!dimensionFound && oldContent.indexOf("dimension", index) == index) { - newContent += "dimension \"${dimensionName}\""; - dimensionFound = true; - index += "dimension ".length(); - def openingQuoutes = oldContent.indexOf('"', index); - if (openingQuoutes == -1) { - openingQuoutes = oldContent.indexOf("'", index); - } - - def closingQuotes = oldContent.indexOf('"', openingQuoutes + 1); - if (closingQuotes == -1) { - closingQuotes = oldContent.indexOf("'", openingQuoutes + 1); - } - - index = closingQuotes + 1; - } - } - - newContent += oldContent[index]; - - index++; - } - - return newContent; -} - -static def createProductFlavorsContent(flavor, dimensionName, includeAndroidContent = true) { - if (includeAndroidContent) - { - def content = """ -android { - productFlavors { - "${flavor}" { - dimension "${dimensionName}" - } - } -} -""" - return content; - } - else - { - def content = """ - productFlavors { - "${flavor}" { - dimension "${dimensionName}" - } - } -""" - return content; - } -} - -static def sanitizeDimensionName(str) { - return str.replaceAll(/\W/, "") -} - -static def modifyProductFlavorInContent(content, dimension, flavor) { - def indexStart = content.indexOf("productFlavors"); - def index = indexStart + "productFlavors".length(); - def indexEnd = -1; - def nestedOpenBracketsCount = 0; - - while (index < content.length()) - { - // print content[index]; - if (content[index] == "}") - { - nestedOpenBracketsCount--; - - if (nestedOpenBracketsCount == 0) - { - indexEnd = index; - break; - } - } - else if (content[index] == "{") - { - nestedOpenBracketsCount++; - } - - index++; - } - - if (indexEnd != -1) - { - // full content of productFlavors { ... } -> the substring is parenthesis to parenthesis -> { ... } - def oldProductFlavorsText = content.substring(indexStart, indexEnd + 1); - - def newProductFlavorsContent = updateProductFlavorsContent(flavor, dimension, oldProductFlavorsText); - - return content.replace(oldProductFlavorsText, newProductFlavorsContent); - } - else - { - def androidContentExists = content.indexOf("android {") != -1; - def newProductFlavorsContent = createProductFlavorsContent(flavor, dimension, !androidContentExists); - - if (androidContentExists) - { - return content.replace("android {", "android { ${newProductFlavorsContent}"); - } - else - { - return "${newProductFlavorsContent} \t ${content}" - } +allprojects { + repositories { + google() + jcenter() } } -def copyFolder(source, destination) { - if (source.isDirectory()) { - Files.createDirectories(destination.toPath()); - - def sourceFiles = source.list(); - - sourceFiles.each { file -> - def srcFile = new File(source, file); - def destFile = new File(destination, file); - - //Recursive function call - copyFolder(srcFile, destFile); - } - } - else { - // Copy the file content from one place to another - def fileName = source.getName() - def extension = fileName.lastIndexOf(".") != -1 && fileName.lastIndexOf(".") != 0 ? fileName.substring(fileName.lastIndexOf(".") + 1) : ""; - // exclude aars from package, as we've already included it in the compile dependencies, and don't want it taking up space - if (extension == "aar") { - return - } - - Files.copy(source.toPath(), destination.toPath(), java.nio.file.StandardCopyOption.REPLACE_EXISTING); - } +task clean(type: Delete) { + delete rootProject.buildDir } - -def copyAndRenamePluginDirToFlavorName(directory, flavor) { - def targetDir = file("src/${flavor}") - - copyFolder(directory, targetDir) -} - -task ensureMetadataOutDir { - def outputDir = file("$projectDir/metadata/output/assets/metadata") - outputDir.mkdirs() -} - -//////////////////////////////////////////////////////////////////////////////////// -///////////////////////////// EXECUTUION PHASE ///////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////// - -task collectAllJars { - description "gathers all paths to jar dependencies before building metadata with them" - - def explodedAarDir = project.buildDir.getAbsolutePath() + "/intermediates/exploded-aar/" - def sdkPath = android.sdkDirectory.getAbsolutePath(); - def androidJar = sdkPath + "/platforms/" + android.compileSdkVersion + "/android.jar" - - doFirst { - configurations.compile.each { File dependencyFile -> - logger.info("Task: collectAllJars: dependency file: " + dependencyFile.getAbsolutePath()) - allJarPaths.add(dependencyFile.getAbsolutePath()) - } - - allJarPaths.add(androidJar); - - def ft = fileTree(dir: explodedAarDir, include: "**/*.jar") - ft.each { currentJarFile -> - allJarPaths.add(currentJarFile.getAbsolutePath()) - } - - metadataParams.add("metadata-generator.jar"); - metadataParams.add("$projectDir/metadata/output/assets/metadata"); - def jars = new LinkedList() - for (def i = 0; i < allJarPaths.size(); i++) { - metadataParams.add(allJarPaths.get(i)); - def f = new File(allJarPaths.get(i)) - if (f.getName().endsWith(".jar")) { - jars.add(f) - } - } - - asbgProject.ext.jarFiles = jars - } -} - -task buildMetadata (type: JavaExec) { - description "builds metadata with provided jar dependencies" - - inputs.files(allJarPaths) - inputs.dir("$buildDir/intermediates/classes") - - outputs.files("metadata/output/assets/metadata/treeNodeStream.dat", "metadata/output/assets/metadata/treeStringsStream.dat", "metadata/output/assets/metadata/treeValueStream.dat") - - doFirst { - // get compiled classes to pass to metadata generator - // these need to be called after the classes have compiled - def classesDir = "$buildDir/intermediates/classes" - - def classesSubDirs = new File(classesDir).listFiles() - def selectedBuildType = project.ext.selectedBuildType - - for (File subDir: classesSubDirs) { - if (!subDir.getName().equals(selectedBuildType)) { - def subDirBuildType = new File(subDir, selectedBuildType) - if (subDirBuildType.exists()) { - metadataParams.add(subDirBuildType.getAbsolutePath()); - } - } - } - - def classesDirBuildType = new File(classesDir, selectedBuildType) - if (classesDirBuildType.exists()) { - metadataParams.add(classesDirBuildType.getAbsolutePath()) - } - - workingDir "build-tools" - main "-jar" - - logger.info("Task buildMetadata: Call metadata-generator.jar with arguments: " + metadataParams.toString().replaceAll(',', '')) - args metadataParams.toArray() - } - - doLast { - copy { - from "$projectDir/metadata/output/assets/metadata" - into "$projectDir/src/main/assets/metadata" - } - } -} - -task generateTypescriptDefinitions (type: JavaExec) { - def paramz = new ArrayList(); - def includeDirs = ["com.android.support", "/platforms/" + android.compileSdkVersion] - - doFirst { - delete "build-tools/typings" - - workingDir "build-tools" - - main "-jar" - - paramz.add("dts-generator.jar"); - paramz.add("-input"); - - for (String jarPath: project.jarFiles) { - // don't generate typings for runtime jars and classes - if (shouldIncludeDirForTypings(jarPath, includeDirs)) { - paramz.add(jarPath); - } - } - - paramz.add("-output"); - paramz.add("typings"); - - logger.info("Task generateTypescriptDefinitions: Call dts-generator.jar with arguments: " + paramz.toString().replaceAll(',', '')) - args paramz.toArray(); - } -} - -generateTypescriptDefinitions.onlyIf { - project.hasProperty("generateTypings") && Boolean.parseBoolean(project.generateTypings) -} - -static def shouldIncludeDirForTypings(path, includeDirs) { - for (String p: includeDirs) { - if (path.indexOf(p) > -1) { - return true; - } - } - - return false; -} - -task copyTypings { - doLast { - println "Copied generated typings to application root level. Make sure to import android.d.ts in reference.d.ts" - - copy { - from "$projectDir/build-tools/typings" - into "$projectDir/../../" - } - } -} - -copyTypings.onlyIf { generateTypescriptDefinitions.didWork } - -task validateAppIdMatch { - doLast { - def packageJsonFile = new File("$projectDir/../../package.json"); - def lineSeparator = System.getProperty("line.separator"); - - if (packageJsonFile.exists() && !project.hasProperty("release")) { - String content = packageJsonFile.getText("UTF-8") - def jsonSlurper = new JsonSlurper() - def packageJsonMap = jsonSlurper.parseText(content) - - if (packageJsonMap.nativescript.id != android.defaultConfig.applicationId) { - def errorMessage = "${lineSeparator}WARNING: The Application identifier is different from the one inside 'package.json' file.$lineSeparator" + - "NativeScript CLI might not work properly.$lineSeparator" + - "Update the application identifier in package.json and app.gradle so that they match."; - logger.error(errorMessage); - } - } - } -} - -//////////////////////////////////////////////////////////////////////////////////// -////////////////////////////// OPTIONAL TASKS ////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////// - -task setProperties { - project.ext.jarFiles = [] - doLast { - def list = []; - allJarPaths.each({f -> - if(f.endsWith(".jar")) { - list.add(f); - } - }) - project.jarFiles = list; - } -} - -setProperties.finalizedBy("asbg:generateBindings", generateTypescriptDefinitions) - -//////////////////////////////////////////////////////////////////////////////////// -////////////////////////////// EXECUTION ORDER ///////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////// - -collectAllJars.dependsOn(ensureMetadataOutDir) -buildMetadata.dependsOn(collectAllJars) -generateTypescriptDefinitions.finalizedBy(copyTypings) - -task buildapk { - //done to build only necessary apk - if (project.hasProperty("release")) { - dependsOn "assembleRelease" - } - else { - dependsOn "assembleDebug" - } -} - -//////// custom clean /////////// -task deleteMetadata (type: Delete){ - delete "$projectDir/metadata/output", "$projectDir/src/main/assets/metadata" -} - -task deleteFlavors (type: Delete){ - doLast { - def srcDir = new File("$projectDir/src") - srcDir.listFiles().each({ f -> - def dirName = f.getName() - if (dirName != "main" && - dirName != "debug" && - dirName != "release") { - delete f - } - }) - } -} - -task deleteGeneratedBindings(type: Delete) { - delete "$projectDir/src/main/java/com/tns/gen" -} - -buildapk.finalizedBy("validateAppIdMatch"); -deleteMetadata.dependsOn(":asbg:clean") -deleteFlavors.dependsOn(deleteMetadata) -deleteGeneratedBindings.dependsOn(deleteFlavors) -clean.dependsOn(deleteGeneratedBindings) diff --git a/build-artifacts/project-template-gradle/gradle.properties b/build-artifacts/project-template-gradle/gradle.properties index 47bae1943..52749577c 100644 --- a/build-artifacts/project-template-gradle/gradle.properties +++ b/build-artifacts/project-template-gradle/gradle.properties @@ -1,2 +1,17 @@ -android.useDeprecatedNdk = true +# Project-wide Gradle settings. + +# IDE (e.g. Android Studio) users: +# Gradle settings configured through the IDE *will override* +# any settings specified in this file. + +# For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html + +# When configured, Gradle will run in incubating parallel mode. +# This option should only be used with decoupled projects. More details, visit +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects +# org.gradle.parallel=true + +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. org.gradle.jvmargs=-Xmx16384M diff --git a/build-artifacts/project-template-gradle/gradle/wrapper/gradle-wrapper.jar b/build-artifacts/project-template-gradle/gradle/wrapper/gradle-wrapper.jar index df9f043ef..3e68357b7 100644 Binary files a/build-artifacts/project-template-gradle/gradle/wrapper/gradle-wrapper.jar and b/build-artifacts/project-template-gradle/gradle/wrapper/gradle-wrapper.jar differ diff --git a/build-artifacts/project-template-gradle/gradle/wrapper/gradle-wrapper.properties b/build-artifacts/project-template-gradle/gradle/wrapper/gradle-wrapper.properties index f843584bb..666911124 100644 --- a/build-artifacts/project-template-gradle/gradle/wrapper/gradle-wrapper.properties +++ b/build-artifacts/project-template-gradle/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Wed Jan 11 14:44:42 EET 2017 +#Thu Oct 26 15:50:33 EEST 2017 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip diff --git a/build-artifacts/project-template-gradle/settings.gradle b/build-artifacts/project-template-gradle/settings.gradle index 235dc9dd7..03eb8c27f 100644 --- a/build-artifacts/project-template-gradle/settings.gradle +++ b/build-artifacts/project-template-gradle/settings.gradle @@ -1,6 +1,3 @@ rootProject.name = "__PROJECT_NAME__" -include "asbg" -project(":asbg").projectDir = file("build-tools/android-static-binding-generator") - -include "runtime" -project(":runtime").projectDir = file("build-tools/runtime-modules/runtime") \ No newline at end of file +include ':app', ':asbg' +project(':asbg').projectDir = new File('build-tools/android-static-binding-generator') diff --git a/build.gradle b/build.gradle index 6d6dd8278..ffb8813d9 100644 --- a/build.gradle +++ b/build.gradle @@ -55,11 +55,11 @@ task copyFilesToProjectTemeplate { from "$rootDir/test-app/app/src/main/java/com/tns/ErrorReport.java" from "$rootDir/test-app/app/src/main/java/com/tns/ErrorReportActivity.java" from "$rootDir/test-app/app/src/main/java/com/tns/NativeScriptSyncService.java" - into "$rootDir/build-artifacts/project-template-gradle/src/debug/java/com/tns/" + into "$rootDir/build-artifacts/project-template-gradle/app/src/debug/java/com/tns/" } copy { from "$rootDir/test-app/app/src/main/assets/internal" - into "$rootDir/build-artifacts/project-template-gradle/src/main/assets/internal" + into "$rootDir/build-artifacts/project-template-gradle/app/src/main/assets/internal" } copy { from "$rootDir/test-app/app/src/main/java/com/tns/AndroidJsV8Inspector.java" @@ -69,11 +69,11 @@ task copyFilesToProjectTemeplate { from "$rootDir/test-app/app/src/main/java/com/tns/NativeScriptUncaughtExceptionHandler.java" from "$rootDir/test-app/app/src/main/java/com/tns/RuntimeHelper.java" from "$rootDir/test-app/app/src/main/java/com/tns/Util.java" - into "$rootDir/build-artifacts/project-template-gradle/src/main/java/com/tns/" + into "$rootDir/build-artifacts/project-template-gradle/app/src/main/java/com/tns/" } copy { from "$rootDir/test-app/app/src/main/java/com/tns/internal" - into "$rootDir/build-artifacts/project-template-gradle/src/main/java/com/tns/internal" + into "$rootDir/build-artifacts/project-template-gradle/app/src/main/java/com/tns/internal" } } } @@ -164,13 +164,13 @@ task copyGeneratedRuntime { doLast { copy { from "$rootDir/test-app/runtime/build/outputs/aar/runtime-regular-release.aar" - into "$rootDir/dist/framework/libs/runtime-libs/" + into "$rootDir/dist/framework/app/libs/runtime-libs/" rename "runtime-regular-release.aar", "nativescript-regular.aar" } copy { from "$rootDir/test-app/runtime/build/outputs/aar/runtime-optimized-release.aar" - into "$rootDir/dist/framework/libs/runtime-libs/" + into "$rootDir/dist/framework/app/libs/runtime-libs/" rename "runtime-optimized-release.aar", "nativescript-optimized.aar" } } @@ -284,9 +284,9 @@ task copyReadme(type: Copy) { } task cleanBuildArtefacts(type: Delete) { - delete "$rootDir/build-artifacts/project-template-gradle/src/debug/java" - delete "$rootDir/build-artifacts/project-template-gradle/src/main/java" - delete "$rootDir/build-artifacts/project-template-gradle/src/main/assets" + delete "$rootDir/build-artifacts/project-template-gradle/app/src/debug/java" + delete "$rootDir/build-artifacts/project-template-gradle/app/src/main/java" + delete "$rootDir/build-artifacts/project-template-gradle/app/src/main/assets" } //clean and set up dirs diff --git a/test-app/runtime/build.gradle b/test-app/runtime/build.gradle index a18731847..cdbf0f78b 100644 --- a/test-app/runtime/build.gradle +++ b/test-app/runtime/build.gradle @@ -66,7 +66,6 @@ android { dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') - compile 'com.android.support:appcompat-v7:26.0.2' } tasks.whenTaskAdded { task -> diff --git a/test-app/test-app.iml b/test-app/test-app.iml index a2d28c6cd..6a2a0b6b4 100644 --- a/test-app/test-app.iml +++ b/test-app/test-app.iml @@ -1,5 +1,5 @@ - +