Update maven artifacts and add lint.

Updated the groupId of most artifacts to be more
reflective of their sub-projects status in the SDK tools.

Added lint artifacts.

Change-Id: I900a165647a9b7d3c55b473f63c4ca4469762d7b
diff --git a/build.gradle b/build.gradle
index 982e93a..d529d1b 100644
--- a/build.gradle
+++ b/build.gradle
@@ -9,12 +9,15 @@
         mavenCentral()
     }
 
-    group = 'com.android.tools'
-
     project.ext {
         baseVersion = '21.0'
     }
 
+    // set all java compilation to use UTF-8 encoding.
+    tasks.withType(JavaCompile) {
+        options.encoding = 'UTF-8'
+    }
+
     // custom tasks for creating source/javadoc jars
     task sourcesJar(type: Jar, dependsOn:classes) {
         classifier = 'sources'
diff --git a/common/build.gradle b/common/build.gradle
index 258f5e0..a390c9d 100644
--- a/common/build.gradle
+++ b/common/build.gradle
@@ -13,6 +13,7 @@
 }
 
 version = getVersion()
+group = 'com.android.tools'
 archivesBaseName = 'common'
 
 sourceSets {
diff --git a/ddms/libs/ddmlib/build.gradle b/ddms/libs/ddmlib/build.gradle
index d765588..7e635fe 100644
--- a/ddms/libs/ddmlib/build.gradle
+++ b/ddms/libs/ddmlib/build.gradle
@@ -12,6 +12,7 @@
 }
 
 version = getVersion()
+group = 'com.android.tools.ddms'
 archivesBaseName = 'ddmlib'
 
 sourceSets {
diff --git a/device_validator/dvlib/build.gradle b/device_validator/dvlib/build.gradle
index 0681e75..0486fa6 100644
--- a/device_validator/dvlib/build.gradle
+++ b/device_validator/dvlib/build.gradle
@@ -11,6 +11,7 @@
 }
 
 version = getVersion()
+group = 'com.android.tools'
 archivesBaseName = 'dvlib'
 
 sourceSets {
diff --git a/layoutlib_api/build.gradle b/layoutlib_api/build.gradle
index 24e1a65..82a2af4 100644
--- a/layoutlib_api/build.gradle
+++ b/layoutlib_api/build.gradle
@@ -14,7 +14,8 @@
 }
 
 version = getVersion()
-archivesBaseName = 'layoutlib_api'
+group = 'com.android.tools.layoutlib'
+archivesBaseName = 'layoutlib-api'
 
 sourceSets {
     main {
diff --git a/layoutlib_api/src/com/android/ide/common/rendering/api/SessionParams.java b/layoutlib_api/src/com/android/ide/common/rendering/api/SessionParams.java
index f440de1..709207e 100644
--- a/layoutlib_api/src/com/android/ide/common/rendering/api/SessionParams.java
+++ b/layoutlib_api/src/com/android/ide/common/rendering/api/SessionParams.java
@@ -60,17 +60,12 @@
      * layout file.
      * @param renderingMode The rendering mode.
      * @param projectKey An Object identifying the project. This is used for the cache mechanism.
-     * @param screenWidth the screen width
-     * @param screenHeight the screen height
-     * @param density the density factor for the screen.
-     * @param xdpi the screen actual dpi in X
-     * @param ydpi the screen actual dpi in Y
-    * @param renderResources a {@link RenderResources} object providing access to the resources.
+     * @param hardwareConfig the {@link HardwareConfig}.
+     * @param renderResources a {@link RenderResources} object providing access to the resources.
      * @param projectCallback The {@link IProjectCallback} object to get information from
      * the project.
      * @param minSdkVersion the minSdkVersion of the project
      * @param targetSdkVersion the targetSdkVersion of the project
-     * @param softwareButtons whether the device use software buttons
      * @param log the object responsible for displaying warning/errors to the user.
      */
     public SessionParams(
diff --git a/lint/.gitignore b/lint/.gitignore
index 99d9ac8..247246d 100644
--- a/lint/.gitignore
+++ b/lint/.gitignore
@@ -1,4 +1,7 @@
 cli/bin
+cli/build
 libs/lint_api/bin
+libs/lint_api/build
 libs/lint_checks/bin
+libs/lint_checks/build
 libs/lint_checks/tests/bin
diff --git a/lint/cli/build.gradle b/lint/cli/build.gradle
new file mode 100644
index 0000000..7cd02dc
--- /dev/null
+++ b/lint/cli/build.gradle
@@ -0,0 +1,85 @@
+dependencies {
+    compile project(':lint_api')
+    compile project(':lint_checks')
+
+    testCompile 'org.easymock:easymock:3.1'
+    testCompile 'junit:junit:3.8.1'
+}
+
+def getVersion() {
+    if (project.has("release")) {
+        return project.ext.baseVersion
+    }
+
+    return project.ext.baseVersion + '-SNAPSHOT'
+}
+
+version = getVersion()
+group = 'com.android.tools.lint'
+archivesBaseName = 'lint'
+
+sourceSets {
+    main {
+        java {
+            srcDir 'src'
+        }
+        resources {
+            srcDir 'src'
+        }
+    }
+    test {
+        java {
+            srcDir 'tests/src'
+        }
+        resources {
+            srcDir 'tests/src'
+        }
+    }
+}
+
+jar {
+    manifest { attributes 'Main-Class': 'com.android.tools.lint.Main' }
+}
+
+uploadArchives {
+    repositories {
+        mavenDeployer {
+            beforeDeployment { MavenDeployment deployment ->
+                if (!project.has("release")) {
+                    throw new StopExecutionException("uploadArchives must be called with the release.gradle init script")
+                }
+
+                signing.signPom(deployment)
+            }
+
+            repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
+                authentication(userName: sonatypeUsername, password: sonatypePassword)
+            }
+
+            pom.project {
+                name 'Android Lint Tool'
+                description 'Lint tools. Both a Command line tool and a library to add lint features to other tools'
+                url 'http://tools.android.com'
+                inceptionYear '2007'
+
+                licenses {
+                    license {
+                        name 'The Apache Software License, Version 2.0'
+                        url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
+                        distribution 'repo'
+                    }
+                }
+
+                scm {
+                    url "https://android.googlesource.com/platform/sdk"
+                    connection "git://android.googlesource.com/platform/sdk.git"
+                }
+                developers {
+                    developer {
+                        name 'The Android Open Source Project'
+                    }
+                }
+            }
+        }
+    }
+}
diff --git a/lint/libs/lint_api/build.gradle b/lint/libs/lint_api/build.gradle
new file mode 100644
index 0000000..315c2bb
--- /dev/null
+++ b/lint/libs/lint_api/build.gradle
@@ -0,0 +1,76 @@
+dependencies {
+    compile project(':common')
+    compile project(':sdklib')
+    compile project(':layoutlib_api')
+
+    compile 'com.google.guava:guava:13.0.1'
+    compile 'org.projectlombok:lombok.ast:0.2'
+    compile 'org.ow2.asm:asm:4.0'
+    compile 'org.ow2.asm:asm-tree:4.0'
+}
+
+def getVersion() {
+    if (project.has("release")) {
+        return project.ext.baseVersion
+    }
+
+    return project.ext.baseVersion + '-SNAPSHOT'
+}
+
+version = getVersion()
+group = 'com.android.tools.lint'
+archivesBaseName = 'lint-api'
+
+sourceSets {
+    main {
+        java {
+            srcDir 'src'
+        }
+        resources {
+            srcDir 'src'
+        }
+    }
+}
+
+uploadArchives {
+    repositories {
+        mavenDeployer {
+            beforeDeployment { MavenDeployment deployment ->
+                if (!project.has("release")) {
+                    throw new StopExecutionException("uploadArchives must be called with the release.gradle init script")
+                }
+
+                signing.signPom(deployment)
+            }
+
+            repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
+                authentication(userName: sonatypeUsername, password: sonatypePassword)
+            }
+
+            pom.project {
+                name 'Android Tools Lint API'
+                description 'API to build lint checks'
+                url 'http://tools.android.com'
+                inceptionYear '2007'
+
+                licenses {
+                    license {
+                        name 'The Apache Software License, Version 2.0'
+                        url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
+                        distribution 'repo'
+                    }
+                }
+
+                scm {
+                    url "https://android.googlesource.com/platform/sdk"
+                    connection "git://android.googlesource.com/platform/sdk.git"
+                }
+                developers {
+                    developer {
+                        name 'The Android Open Source Project'
+                    }
+                }
+            }
+        }
+    }
+}
diff --git a/lint/libs/lint_checks/build.gradle b/lint/libs/lint_checks/build.gradle
new file mode 100644
index 0000000..53a3cf8
--- /dev/null
+++ b/lint/libs/lint_checks/build.gradle
@@ -0,0 +1,82 @@
+dependencies {
+    compile project(':lint_api')
+    compile 'org.ow2.asm:asm-analysis:4.0'
+
+    testCompile 'org.easymock:easymock:3.1'
+    testCompile 'junit:junit:3.8.1'
+    testCompile project(':lint')
+}
+
+def getVersion() {
+    if (project.has("release")) {
+        return project.ext.baseVersion
+    }
+
+    return project.ext.baseVersion + '-SNAPSHOT'
+}
+
+version = getVersion()
+group = 'com.android.tools.lint'
+archivesBaseName = 'lint-checks'
+
+sourceSets {
+    main {
+        java {
+            srcDir 'src'
+        }
+        resources {
+            srcDir 'src'
+        }
+    }
+    test {
+        java {
+            srcDir 'tests/src'
+        }
+        resources {
+            srcDir 'tests/src'
+        }
+    }
+}
+
+uploadArchives {
+    repositories {
+        mavenDeployer {
+            beforeDeployment { MavenDeployment deployment ->
+                if (!project.has("release")) {
+                    throw new StopExecutionException("uploadArchives must be called with the release.gradle init script")
+                }
+
+                signing.signPom(deployment)
+            }
+
+            repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
+                authentication(userName: sonatypeUsername, password: sonatypePassword)
+            }
+
+            pom.project {
+                name 'Android Lint Checks'
+                description 'Checks for Android Lint'
+                url 'http://tools.android.com'
+                inceptionYear '2007'
+
+                licenses {
+                    license {
+                        name 'The Apache Software License, Version 2.0'
+                        url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
+                        distribution 'repo'
+                    }
+                }
+
+                scm {
+                    url "https://android.googlesource.com/platform/sdk"
+                    connection "git://android.googlesource.com/platform/sdk.git"
+                }
+                developers {
+                    developer {
+                        name 'The Android Open Source Project'
+                    }
+                }
+            }
+        }
+    }
+}
diff --git a/lint/libs/lint_checks/tests/src/com/android/tools/lint/checks/AbstractCheckTest.java b/lint/libs/lint_checks/tests/src/com/android/tools/lint/checks/AbstractCheckTest.java
index 9826398..e7774f5 100644
--- a/lint/libs/lint_checks/tests/src/com/android/tools/lint/checks/AbstractCheckTest.java
+++ b/lint/libs/lint_checks/tests/src/com/android/tools/lint/checks/AbstractCheckTest.java
@@ -245,6 +245,7 @@
         }
 
         Files.copy(new InputSupplier<InputStream>() {
+            @Override
             public InputStream getInput() throws IOException {
                 return contents;
             }
@@ -436,38 +437,20 @@
         @Override
         public File findResource(String relativePath) {
             if (relativePath.equals("platform-tools/api/api-versions.xml")) {
-                CodeSource source = getClass().getProtectionDomain().getCodeSource();
-                if (source != null) {
-                    URL location = source.getLocation();
-                    try {
-                        File dir = new File(location.toURI());
-                        assertTrue(dir.getPath(), dir.exists());
-                        File sdkDir = dir.getParentFile().getParentFile().getParentFile()
-                                .getParentFile().getParentFile().getParentFile();
-                        File file = new File(sdkDir, "development" + File.separator + "sdk"
-                                + File.separator + "api-versions.xml");
-                        return file;
-                    } catch (URISyntaxException e) {
-                        fail(e.getLocalizedMessage());
-                    }
+                File rootDir = getRootDir();
+                if (rootDir != null) {
+                    File file = new File(rootDir, "development" + File.separator + "sdk"
+                            + File.separator + "api-versions.xml");
+                    return file;
                 }
             } else if (relativePath.startsWith("tools/support/")) {
                 String base = relativePath.substring("tools/support/".length());
-                CodeSource source = getClass().getProtectionDomain().getCodeSource();
-                if (source != null) {
-                    URL location = source.getLocation();
-                    try {
-                        File dir = new File(location.toURI());
-                        assertTrue(dir.getPath(), dir.exists());
-                        File sdkDir = dir.getParentFile().getParentFile().getParentFile()
-                                .getParentFile().getParentFile().getParentFile();
-                        File file = new File(sdkDir, "sdk" + File.separator + "files"
-                                + File.separator + "typos"
-                                + File.separator + base);
-                        return file;
-                    } catch (URISyntaxException e) {
-                        fail(e.getLocalizedMessage());
-                    }
+                File rootDir = getRootDir();
+                if (rootDir != null) {
+                    File file = new File(rootDir, "sdk" + File.separator + "files"
+                            + File.separator + "typos"
+                            + File.separator + base);
+                    return file;
                 }
             } else {
                 fail("Unit tests don't support arbitrary resource lookup yet.");
@@ -477,6 +460,37 @@
         }
     }
 
+    /**
+     * Returns the Android source tree root dir.
+     * @return the root dir or null if it couldn't be computed.
+     */
+    private File getRootDir() {
+        CodeSource source = getClass().getProtectionDomain().getCodeSource();
+        if (source != null) {
+            URL location = source.getLocation();
+            try {
+                File dir = new File(location.toURI());
+                assertTrue(dir.getPath(), dir.exists());
+                File rootDir = dir.getParentFile().getParentFile().getParentFile()
+                        .getParentFile().getParentFile().getParentFile();
+
+                // check if "settings.gradle" is there. This will let us know if we need
+                // to go up one extra level, which is the case when running the tests
+                // from gradle.
+                File settingsGradle = new File(rootDir, "settings.gradle"); //$NON-NLS-1$
+                if (settingsGradle.isFile()) {
+                    rootDir = rootDir.getParentFile();
+                }
+
+                return rootDir;
+            } catch (URISyntaxException e) {
+                fail(e.getLocalizedMessage());
+            }
+        }
+
+        return null;
+    }
+
     public class TestConfiguration extends Configuration {
         @Override
         public boolean isEnabled(Issue issue) {
diff --git a/manifmerger/build.gradle b/manifmerger/build.gradle
index 57c930b..1db9c04 100644
--- a/manifmerger/build.gradle
+++ b/manifmerger/build.gradle
@@ -16,6 +16,7 @@
 }
 
 version = getVersion()
+group = 'com.android.tools.build'
 archivesBaseName = 'manifest-merger'
 
 sourceSets {
diff --git a/sdkmanager/libs/sdklib/build.gradle b/sdkmanager/libs/sdklib/build.gradle
index ce03920..346dc6b 100644
--- a/sdkmanager/libs/sdklib/build.gradle
+++ b/sdkmanager/libs/sdklib/build.gradle
@@ -20,6 +20,7 @@
 }
 
 version = getVersion()
+group = 'com.android.tools.sdk'
 archivesBaseName = 'sdklib'
 
 sourceSets {
diff --git a/settings.gradle b/settings.gradle
index 4af1084..f10b6a4 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -4,7 +4,13 @@
 include 'sdklib'
 include 'ddmlib'
 include 'manifmerger'
+include 'lint_api'
+include 'lint_checks'
+include 'lint'
 
 project(':dvlib').projectDir = new File('device_validator/dvlib')
 project(':sdklib').projectDir = new File('sdkmanager/libs/sdklib')
-project(':ddmlib').projectDir = new File('ddms/libs/ddmlib')
\ No newline at end of file
+project(':ddmlib').projectDir = new File('ddms/libs/ddmlib')
+project(':lint_api').projectDir = new File('lint/libs/lint_api')
+project(':lint_checks').projectDir = new File('lint/libs/lint_checks')
+project(':lint').projectDir = new File('lint/cli')
\ No newline at end of file