diff options
author | Harsh Shandilya <me@msfjarvis.dev> | 2020-03-09 19:03:06 +0530 |
---|---|---|
committer | Harsh Shandilya <me@msfjarvis.dev> | 2020-03-09 19:24:26 +0530 |
commit | 6bc3e257f80a273d35d07099bd4ed99eb45163bf (patch) | |
tree | 49a9a71d6bb703cb0a56a08a0d7a5bec92e7686a /app | |
parent | adc613d8011af7c508050badb1272e8326554c39 (diff) |
Enable nonnull generation for tunnel module
Also cleanup nonnull.gradle while we're at it
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
Diffstat (limited to 'app')
-rw-r--r-- | app/build.gradle | 2 | ||||
-rw-r--r-- | app/nonnull.gradle | 87 |
2 files changed, 1 insertions, 88 deletions
diff --git a/app/build.gradle b/app/build.gradle index a21c2027..e4caeb6b 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,6 +1,6 @@ apply plugin: 'com.android.application' apply plugin: 'kotlin-android' -apply from: 'nonnull.gradle' +apply from: rootProject.file('nonnull.gradle') // Create a variable called keystorePropertiesFile, and initialize it to your // keystore.properties file, in the rootProject folder. diff --git a/app/nonnull.gradle b/app/nonnull.gradle deleted file mode 100644 index a10c10d2..00000000 --- a/app/nonnull.gradle +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright © 2017-2019 WireGuard LLC. All Rights Reserved. - * SPDX-License-Identifier: Apache-2.0 - */ - -task generateNonNullJavaFiles(dependsOn: "assembleDebug", type: Copy) { - group = "Copying" - description = "Generate package-info.java classes" - - def basePackage = "com" + File.separatorChar + "wireguard" - def mainSrcPhrase = "src" + File.separatorChar + "main" + File.separatorChar + - "java" + File.separatorChar - def mainTestSrcPhrase = "src" + File.separatorChar + "test" + File.separatorChar + - "java" + File.separatorChar - def mainAndroidTestSrcPhrase = "src" + File.separatorChar + "androidTest" + File.separatorChar + - "java" + File.separatorChar - - def sourceDir = file( "${projectDir}" + File.separatorChar + "src" + File.separatorChar + - "main" + File.separatorChar + "java" + File.separatorChar + - basePackage ) - def testSourceDir = file( "${projectDir}" + File.separatorChar + "src" + File.separatorChar + - "test" + File.separatorChar + "java" + File.separatorChar + - basePackage) - def androidTestSourceDir = file( "${projectDir}" + File.separatorChar + "src" + File - .separatorChar + - "androidTest" + File.separatorChar + "java" + File.separatorChar + - basePackage ) - - generateInfoFiles(sourceDir, mainSrcPhrase); - sourceDir.eachDirRecurse { dir -> - generateInfoFiles(dir, mainSrcPhrase) - } - if (file(testSourceDir).exists()) { - generateInfoFiles(testSourceDir, mainTestSrcPhrase); - testSourceDir.eachDirRecurse { dir -> - generateInfoFiles(dir, mainTestSrcPhrase) - } - } - if (file(androidTestSourceDir).exists()) { - generateInfoFiles(androidTestSourceDir, mainAndroidTestSrcPhrase); - androidTestSourceDir.eachDirRecurse { dir -> - generateInfoFiles(dir, mainAndroidTestSrcPhrase) - } - } - println "[SUCCESS] NonNull generator: package-info.java files checked" -} - -private void generateInfoFiles(File dir, String mainSrcPhrase) { - def infoFileContentHeader = getFileContentHeader(); - def infoFileContentFooter = getFileContentFooter(); - def infoFilePath = dir.getAbsolutePath() + File.separatorChar + "package-info.java" - - //file(infoFilePath).delete(); //do not use in production code - if (!file(infoFilePath).exists()) { - def infoFileContentPackage = getFileContentPackage(dir.getAbsolutePath(), mainSrcPhrase); - new File(infoFilePath).write(infoFileContentHeader + - infoFileContentPackage + infoFileContentFooter) - println "[dir] " + infoFilePath + " created"; - } -} - -def getFileContentPackage(String path, String mainSrcPhrase) { - def mainSrcPhraseIndex = path.indexOf(mainSrcPhrase) - def output = path.substring(mainSrcPhraseIndex) - - // Win hotfix - if (System.properties['os.name'].toLowerCase().contains('windows')) { - output = output.replace("\\", "/") - mainSrcPhrase = mainSrcPhrase.replace("\\", "/") - } - - return "package " + output.replaceAll(mainSrcPhrase, "").replaceAll( - "/", ".") + ";\n" -} - -def getFileContentHeader() { - return "/**\n" + - " * Make all method parameters @NonNull by default.\n" + - " */\n" + - "@NonNullForAll\n" -} - -def getFileContentFooter() { - return "\n" + - "import com.wireguard.util.NonNullForAll;\n" -} - |