summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorHarsh Shandilya <me@msfjarvis.dev>2020-03-09 19:03:06 +0530
committerHarsh Shandilya <me@msfjarvis.dev>2020-03-09 19:24:26 +0530
commit6bc3e257f80a273d35d07099bd4ed99eb45163bf (patch)
tree49a9a71d6bb703cb0a56a08a0d7a5bec92e7686a
parentadc613d8011af7c508050badb1272e8326554c39 (diff)
Enable nonnull generation for tunnel module
Also cleanup nonnull.gradle while we're at it Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
-rw-r--r--app/build.gradle2
-rw-r--r--nonnull.gradle (renamed from app/nonnull.gradle)21
-rw-r--r--tunnel/build.gradle1
3 files changed, 12 insertions, 12 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/nonnull.gradle
index a10c10d2..7fc9b25d 100644
--- a/app/nonnull.gradle
+++ b/nonnull.gradle
@@ -26,18 +26,18 @@ task generateNonNullJavaFiles(dependsOn: "assembleDebug", type: Copy) {
"androidTest" + File.separatorChar + "java" + File.separatorChar +
basePackage )
- generateInfoFiles(sourceDir, mainSrcPhrase);
+ generateInfoFiles(sourceDir, mainSrcPhrase)
sourceDir.eachDirRecurse { dir ->
generateInfoFiles(dir, mainSrcPhrase)
}
if (file(testSourceDir).exists()) {
- generateInfoFiles(testSourceDir, mainTestSrcPhrase);
+ generateInfoFiles(testSourceDir, mainTestSrcPhrase)
testSourceDir.eachDirRecurse { dir ->
generateInfoFiles(dir, mainTestSrcPhrase)
}
}
if (file(androidTestSourceDir).exists()) {
- generateInfoFiles(androidTestSourceDir, mainAndroidTestSrcPhrase);
+ generateInfoFiles(androidTestSourceDir, mainAndroidTestSrcPhrase)
androidTestSourceDir.eachDirRecurse { dir ->
generateInfoFiles(dir, mainAndroidTestSrcPhrase)
}
@@ -46,20 +46,20 @@ task generateNonNullJavaFiles(dependsOn: "assembleDebug", type: Copy) {
}
private void generateInfoFiles(File dir, String mainSrcPhrase) {
- def infoFileContentHeader = getFileContentHeader();
- def infoFileContentFooter = getFileContentFooter();
+ 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);
+ def infoFileContentPackage = getFileContentPackage(dir.getAbsolutePath(), mainSrcPhrase)
new File(infoFilePath).write(infoFileContentHeader +
infoFileContentPackage + infoFileContentFooter)
- println "[dir] " + infoFilePath + " created";
+ println "[dir] " + infoFilePath + " created"
}
}
-def getFileContentPackage(String path, String mainSrcPhrase) {
+static def getFileContentPackage(String path, String mainSrcPhrase) {
def mainSrcPhraseIndex = path.indexOf(mainSrcPhrase)
def output = path.substring(mainSrcPhraseIndex)
@@ -73,15 +73,14 @@ def getFileContentPackage(String path, String mainSrcPhrase) {
"/", ".") + ";\n"
}
-def getFileContentHeader() {
+static def getFileContentHeader() {
return "/**\n" +
" * Make all method parameters @NonNull by default.\n" +
" */\n" +
"@NonNullForAll\n"
}
-def getFileContentFooter() {
+static def getFileContentFooter() {
return "\n" +
"import com.wireguard.util.NonNullForAll;\n"
}
-
diff --git a/tunnel/build.gradle b/tunnel/build.gradle
index 65ac6ceb..984382e1 100644
--- a/tunnel/build.gradle
+++ b/tunnel/build.gradle
@@ -1,4 +1,5 @@
apply plugin: 'com.android.library'
+apply from: rootProject.file('nonnull.gradle')
android {
buildToolsVersion '29.0.3'