diff --git a/README.md b/README.md index b3035f31..c9d45715 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ Custom Lint Rules -============ +================= The [Android `lint` tool](http://developer.android.com/tools/help/lint.html) is a static code analysis tool that checks your Android project source files for potential bugs and optimization @@ -31,31 +31,15 @@ git clone https://github.com/googlesamples/android-custom-lint-rules.git cd android-custom-lint-rules ``` -##### Build the validator +##### Build the code -`./gradlew build` - -##### Copy to the lint directory - -`cp ./build/libs/android-custom-lint-rules.jar ~/.android/lint/` - -##### Verify whether the issues are registered with lint - -`lint --show MainActivityDetector` - -##### Run lint - -`./gradlew lint` - -> Note: If you can't run `lint` directly, you may want to include android tools `PATH` in your - `~/.bash_profile`. -> (i.e. `PATH=$PATH:~/Library/Android/sdk/tools`) -> -> Then run `source ~/.bash_profile`. +For Android Studio 3.x and above, use the sample in `android-studio-3`. +If you are targeting Android Studio 2.x and older, use the sample in `android-studio-2`. Support ------- +- The "lint-dev" Google group: https://groups.google.com/forum/#!forum/lint-dev - Google+ Community: https://plus.google.com/communities/105153134372062985968 - Stack Overflow: http://stackoverflow.com/questions/tagged/android diff --git a/android-studio-2/README.md b/android-studio-2/README.md new file mode 100644 index 00000000..ef3f7823 --- /dev/null +++ b/android-studio-2/README.md @@ -0,0 +1,33 @@ +See README.md in the parent directory for general information. + +Getting Started +--------------- + +##### Fetch code + +``` +git clone https://github.com/googlesamples/android-custom-lint-rules.git +cd android-custom-lint-rules +``` + +##### Build the validator + +`./gradlew build` + +##### Copy to the lint directory + +`cp ./build/libs/android-custom-lint-rules.jar ~/.android/lint/` + +##### Verify whether the issues are registered with lint + +`lint --show MainActivityDetector` + +##### Run lint + +`./gradlew lint` + +> Note: If you can't run `lint` directly, you may want to include android tools `PATH` in your + `~/.bash_profile`. +> (i.e. `PATH=$PATH:~/Library/Android/sdk/tools`) +> +> Then run `source ~/.bash_profile`. diff --git a/build.gradle b/android-studio-2/build.gradle similarity index 93% rename from build.gradle rename to android-studio-2/build.gradle index 277037f6..894bbd46 100644 --- a/build.gradle +++ b/android-studio-2/build.gradle @@ -36,7 +36,7 @@ dependencies { jar { manifest { - attributes("Lint-Registry-v2": "com.example.google.lint.MyIssueRegistry") + attributes("Lint-Registry": "com.example.google.lint.MyIssueRegistry") } } diff --git a/gradle/wrapper/gradle-wrapper.jar b/android-studio-2/gradle/wrapper/gradle-wrapper.jar similarity index 100% rename from gradle/wrapper/gradle-wrapper.jar rename to android-studio-2/gradle/wrapper/gradle-wrapper.jar diff --git a/gradle/wrapper/gradle-wrapper.properties b/android-studio-2/gradle/wrapper/gradle-wrapper.properties similarity index 100% rename from gradle/wrapper/gradle-wrapper.properties rename to android-studio-2/gradle/wrapper/gradle-wrapper.properties diff --git a/gradlew b/android-studio-2/gradlew similarity index 100% rename from gradlew rename to android-studio-2/gradlew diff --git a/gradlew.bat b/android-studio-2/gradlew.bat similarity index 100% rename from gradlew.bat rename to android-studio-2/gradlew.bat diff --git a/src/main/java/com/example/google/lint/MainActivityDetector.java b/android-studio-2/src/main/java/com/example/google/lint/MainActivityDetector.java similarity index 100% rename from src/main/java/com/example/google/lint/MainActivityDetector.java rename to android-studio-2/src/main/java/com/example/google/lint/MainActivityDetector.java diff --git a/src/main/java/com/example/google/lint/ManifestConstants.java b/android-studio-2/src/main/java/com/example/google/lint/ManifestConstants.java similarity index 100% rename from src/main/java/com/example/google/lint/ManifestConstants.java rename to android-studio-2/src/main/java/com/example/google/lint/ManifestConstants.java diff --git a/src/main/java/com/example/google/lint/MyIssueRegistry.java b/android-studio-2/src/main/java/com/example/google/lint/MyIssueRegistry.java similarity index 100% rename from src/main/java/com/example/google/lint/MyIssueRegistry.java rename to android-studio-2/src/main/java/com/example/google/lint/MyIssueRegistry.java diff --git a/src/test/java/com/example/google/lint/MainActivityDetectorTest.java b/android-studio-2/src/test/java/com/example/google/lint/MainActivityDetectorTest.java similarity index 100% rename from src/test/java/com/example/google/lint/MainActivityDetectorTest.java rename to android-studio-2/src/test/java/com/example/google/lint/MainActivityDetectorTest.java diff --git a/android-studio-3/README.md b/android-studio-3/README.md new file mode 100644 index 00000000..1ddb7f6d --- /dev/null +++ b/android-studio-3/README.md @@ -0,0 +1,48 @@ +# Sample Lint Checks + +This project shows how Android Studio 3 (beta 5 and later) handles packaging +of lint rules. + +## Lint Check Jar Library + +First, there's the lint check implementation itself. That's done in the +"checks" project, which just applies the Gradle "java" plugin, and +that project produces a jar. Note that the dependencies for the lint +check project (other than its testing dependencies) must all be "compileOnly": + + dependencies { + compileOnly "com.android.tools.lint:lint-api:$lintVersion" + compileOnly "com.android.tools.lint:lint-checks:$lintVersion" + ... + +## Lint Check AAR Library + +Next, there's a separate Android library project, called "library". This +library doesn't have any code on its own (though it could). However, +in its build.gradle, it specifies this: + + dependencies { + lintChecks project(':checks') + } + +This tells the Gradle plugin to take the output from the "checks" project +and package that as a "lint.jar" payload inside this library's AAR file. +When that's done, any other projects that depends on this library will +automatically be using the lint checks. + +## App Modules + +Note that you don't have to go through the extra "library indirection" +if you have a lint check that you only want to apply to one or more +app modules. You can simply include the `lintChecks` dependency as shown +above there as well, and then lint will include these rules when analyzing +the project. + +## Lint Version + +The lint version of the libraries (specified in this project as the +`lintVersion` variable in build.gradle) should be the same version +that is used by the Gradle plugin. + +If the Gradle plugin version is *X*.*Y*.*Z*, then the Lint library +version is *X+23*.*Y*.*Z*. diff --git a/android-studio-3/build.gradle b/android-studio-3/build.gradle new file mode 100644 index 00000000..c6a7794a --- /dev/null +++ b/android-studio-3/build.gradle @@ -0,0 +1,30 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. + +buildscript { + ext { + gradlePluginVersion = '3.0.0-beta5' + lintVersion = '26.0.0-beta5' + } + + repositories { + google() + jcenter() + } + dependencies { + classpath "com.android.tools.build:gradle:$gradlePluginVersion" + + // NOTE: Do not place your application dependencies here; they belong + // in the individual module build.gradle files + } +} + +allprojects { + repositories { + google() + jcenter() + } +} + +task clean(type: Delete) { + delete rootProject.buildDir +} diff --git a/android-studio-3/checks/.gitignore b/android-studio-3/checks/.gitignore new file mode 100644 index 00000000..796b96d1 --- /dev/null +++ b/android-studio-3/checks/.gitignore @@ -0,0 +1 @@ +/build diff --git a/android-studio-3/checks/build.gradle b/android-studio-3/checks/build.gradle new file mode 100644 index 00000000..e6739f49 --- /dev/null +++ b/android-studio-3/checks/build.gradle @@ -0,0 +1,21 @@ +apply plugin: 'java-library' + +dependencies { + compileOnly "com.android.tools.lint:lint-api:$lintVersion" + compileOnly "com.android.tools.lint:lint-checks:$lintVersion" + testCompile "junit:junit:4.12" + testCompile "com.android.tools.lint:lint:$lintVersion" + testCompile "com.android.tools.lint:lint-tests:$lintVersion" + testCompile "com.android.tools:testutils:$lintVersion" +} + +sourceCompatibility = "1.8" +targetCompatibility = "1.8" + +jar { + manifest { + // Only use the "-v2" key here if your checks have been updated to the + // new 3.0 APIs (including UAST) + attributes("Lint-Registry-v2": "com.example.lint.checks.SampleIssueRegistry") + } +} diff --git a/android-studio-3/checks/src/main/java/com/example/lint/checks/SampleCodeDetector.java b/android-studio-3/checks/src/main/java/com/example/lint/checks/SampleCodeDetector.java new file mode 100644 index 00000000..9583af6d --- /dev/null +++ b/android-studio-3/checks/src/main/java/com/example/lint/checks/SampleCodeDetector.java @@ -0,0 +1,93 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.example.lint.checks; + +import com.android.tools.lint.client.api.UElementHandler; +import com.android.tools.lint.detector.api.Category; +import com.android.tools.lint.detector.api.Detector; +import com.android.tools.lint.detector.api.Detector.UastScanner; +import com.android.tools.lint.detector.api.Implementation; +import com.android.tools.lint.detector.api.Issue; +import com.android.tools.lint.detector.api.JavaContext; +import com.android.tools.lint.detector.api.Scope; +import com.android.tools.lint.detector.api.Severity; + +import org.jetbrains.uast.UElement; +import org.jetbrains.uast.ULiteralExpression; +import org.jetbrains.uast.UastLiteralUtils; + +import java.util.Collections; +import java.util.List; + +/** + * Sample detector showing how to analyze Kotlin/Java code. + * This example flags all string literals in the code that contain + * the word "lint". + */ +public class SampleCodeDetector extends Detector implements UastScanner { + /** Issue describing the problem and pointing to the detector implementation */ + public static final Issue ISSUE = Issue.create( + // ID: used in @SuppressLint warnings etc + "ShortUniqueId", + + // Title -- shown in the IDE's preference dialog, as category headers in the + // Analysis results window, etc + "Lint Mentions", + + // Full explanation of the issue; you can use some markdown markup such as + // `monospace`, *italic*, and **bold**. + "This check highlights string literals in code which mentions " + + "the word `lint`. Blah blah blah.\n" + + "\n" + + "Another paragraph here.\n", + Category.CORRECTNESS, + 6, + Severity.WARNING, + new Implementation( + SampleCodeDetector.class, + Scope.JAVA_FILE_SCOPE)); + + @Override + public List> getApplicableUastTypes() { + return Collections.singletonList(ULiteralExpression.class); + } + + @Override + public UElementHandler createUastHandler(JavaContext context) { + // Not: Visiting UAST nodes is a pretty general purpose mechanism; + // Lint has specialized support to do common things like "visit every class + // that extends a given super class or implements a given interface", and + // "visit every call site that calls a method by a given name" etc. + // Take a careful look at UastScanner and the various existing lint check + // implementations before doing things the "hard way". + // Also be aware of context.getJavaEvaluator() which provides a lot of + // utility functionality. + return new UElementHandler() { + @Override + public void visitLiteralExpression(ULiteralExpression expression) { + String string = UastLiteralUtils.getValueIfStringLiteral(expression); + if (string == null) { + return; + } + + if (string.contains("lint") && string.matches(".*\\blint\\b.*")) { + context.report(ISSUE, expression, context.getLocation(expression), + "This code mentions `lint`: **Congratulations**"); + } + } + }; + } +} diff --git a/android-studio-3/checks/src/main/java/com/example/lint/checks/SampleIssueRegistry.java b/android-studio-3/checks/src/main/java/com/example/lint/checks/SampleIssueRegistry.java new file mode 100644 index 00000000..d5561fd3 --- /dev/null +++ b/android-studio-3/checks/src/main/java/com/example/lint/checks/SampleIssueRegistry.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.example.lint.checks; + +import com.android.tools.lint.client.api.IssueRegistry; +import com.android.tools.lint.detector.api.Issue; + +import java.util.Collections; +import java.util.List; + +/* + * The list of issues that will be checked when running lint. + */ +public class SampleIssueRegistry extends IssueRegistry { + @Override + public List getIssues() { + return Collections.singletonList(SampleCodeDetector.ISSUE); + } +} + diff --git a/android-studio-3/checks/src/test/java/com/example/lint/checks/SampleCodeDetectorTest.java b/android-studio-3/checks/src/test/java/com/example/lint/checks/SampleCodeDetectorTest.java new file mode 100644 index 00000000..e6c7e8a4 --- /dev/null +++ b/android-studio-3/checks/src/test/java/com/example/lint/checks/SampleCodeDetectorTest.java @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.example.lint.checks; + +import com.android.tools.lint.checks.infrastructure.LintDetectorTest; +import com.android.tools.lint.detector.api.Detector; +import com.android.tools.lint.detector.api.Issue; + +import java.util.Collections; +import java.util.List; + +public class SampleCodeDetectorTest extends LintDetectorTest { + public void testBasic() { + lint().files( + java("" + + "package test.pkg;\n" + + "public class TestClass1 {\n" + + " // In a comment, mentioning \"lint\" has no effect\n" + + " private static String s1 = \"Ignore non-word usages: linting\";\n" + + " private static String s2 = \"Let's say it: lint\";\n" + + "}")) + .run() + .expect("src/test/pkg/TestClass1.java:5: Warning: This code mentions lint: Congratulations [ShortUniqueId]\n" + + " private static String s2 = \"Let's say it: lint\";\n" + + " ~~~~~~~~~~~~~~~~~~~~\n" + + "0 errors, 1 warnings\n"); + } + + @Override + protected Detector getDetector() { + return new SampleCodeDetector(); + } + + @Override + protected List getIssues() { + return Collections.singletonList(SampleCodeDetector.ISSUE); + } +} \ No newline at end of file diff --git a/android-studio-3/gradle.properties b/android-studio-3/gradle.properties new file mode 100644 index 00000000..aac7c9b4 --- /dev/null +++ b/android-studio-3/gradle.properties @@ -0,0 +1,17 @@ +# 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 + +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +org.gradle.jvmargs=-Xmx1536m + +# 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 diff --git a/android-studio-3/gradle/wrapper/gradle-wrapper.jar b/android-studio-3/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 00000000..13372aef Binary files /dev/null and b/android-studio-3/gradle/wrapper/gradle-wrapper.jar differ diff --git a/android-studio-3/gradle/wrapper/gradle-wrapper.properties b/android-studio-3/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000..613f5fb9 --- /dev/null +++ b/android-studio-3/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Fri Sep 01 06:52:38 PDT 2017 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip diff --git a/android-studio-3/gradlew b/android-studio-3/gradlew new file mode 100755 index 00000000..9d82f789 --- /dev/null +++ b/android-studio-3/gradlew @@ -0,0 +1,160 @@ +#!/usr/bin/env bash + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn ( ) { + echo "$*" +} + +die ( ) { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; +esac + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules +function splitJvmOpts() { + JVM_OPTS=("$@") +} +eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS +JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" + +exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" diff --git a/android-studio-3/gradlew.bat b/android-studio-3/gradlew.bat new file mode 100644 index 00000000..aec99730 --- /dev/null +++ b/android-studio-3/gradlew.bat @@ -0,0 +1,90 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windowz variants + +if not "%OS%" == "Windows_NT" goto win9xME_args +if "%@eval[2+2]" == "4" goto 4NT_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* +goto execute + +:4NT_args +@rem Get arguments from the 4NT Shell from JP Software +set CMD_LINE_ARGS=%$ + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/android-studio-3/library/.gitignore b/android-studio-3/library/.gitignore new file mode 100644 index 00000000..796b96d1 --- /dev/null +++ b/android-studio-3/library/.gitignore @@ -0,0 +1 @@ +/build diff --git a/android-studio-3/library/build.gradle b/android-studio-3/library/build.gradle new file mode 100644 index 00000000..c6c26b67 --- /dev/null +++ b/android-studio-3/library/build.gradle @@ -0,0 +1,18 @@ +apply plugin: 'com.android.library' + +android { + compileSdkVersion 26 + defaultConfig { + minSdkVersion 15 + targetSdkVersion 26 + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +/** Package the given lint checks library into this AAR */ +dependencies { + lintChecks project(':checks') +} diff --git a/android-studio-3/library/src/main/AndroidManifest.xml b/android-studio-3/library/src/main/AndroidManifest.xml new file mode 100644 index 00000000..843049f7 --- /dev/null +++ b/android-studio-3/library/src/main/AndroidManifest.xml @@ -0,0 +1,3 @@ + + + diff --git a/android-studio-3/settings.gradle b/android-studio-3/settings.gradle new file mode 100644 index 00000000..b613efff --- /dev/null +++ b/android-studio-3/settings.gradle @@ -0,0 +1 @@ +include ':checks', ':library'