aboutsummaryrefslogtreecommitdiffstats
path: root/eclipse/plugins
diff options
context:
space:
mode:
authorXavier Ducrohet <xav@android.com>2010-09-01 19:38:02 -0700
committerXavier Ducrohet <xav@android.com>2010-09-01 19:55:41 -0700
commit59f8d5012426884e40b77b02a7c3274eb66019a1 (patch)
tree6ffd75ea4533df95c49a29db3b8e4484d16f8d1f /eclipse/plugins
parent3d3c3c3a3e4e05f7ae7a0dff440fe500f90b785c (diff)
downloadsdk-59f8d5012426884e40b77b02a7c3274eb66019a1.zip
sdk-59f8d5012426884e40b77b02a7c3274eb66019a1.tar.gz
sdk-59f8d5012426884e40b77b02a7c3274eb66019a1.tar.bz2
ADT refactor the builders into their own package.
Put the growing list of generic build classes into the main build package. Change-Id: I65d7067bb2547d7cc9b71674f4df8a6778dd8ac8
Diffstat (limited to 'eclipse/plugins')
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/plugin.xml6
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/AndroidConstants.java9
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/actions/MultiApkExportAction.java6
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/AaptExecException.java29
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/AaptParser.java6
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/AaptResultException.java47
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/BuildHelper.java (renamed from eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/PostCompilerHelper.java)146
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/DexException.java33
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/DexWrapper.java (renamed from eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/sdk/DexWrapper.java)3
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/NativeLibInJarException.java61
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/builders/BaseBuilder.java (renamed from eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/BaseBuilder.java)74
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/builders/LibraryDeltaVisitor.java (renamed from eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/LibraryDeltaVisitor.java)2
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/builders/PostCompilerBuilder.java (renamed from eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/PostCompilerBuilder.java)25
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/builders/PostCompilerDeltaVisitor.java (renamed from eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/PostCompilerDeltaVisitor.java)9
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/builders/PreCompilerBuilder.java (renamed from eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/PreCompilerBuilder.java)4
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/builders/PreCompilerDeltaVisitor.java (renamed from eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/PreCompilerDeltaVisitor.java)7
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/builders/ResourceManagerBuilder.java (renamed from eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/ResourceManagerBuilder.java)3
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/AndroidNature.java6
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/ExportHelper.java6
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/sdk/AndroidTargetData.java1
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/sdk/AndroidTargetParser.java1
21 files changed, 298 insertions, 186 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/plugin.xml b/eclipse/plugins/com.android.ide.eclipse.adt/plugin.xml
index 9eb522a..bd92a97 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/plugin.xml
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/plugin.xml
@@ -47,7 +47,7 @@
point="org.eclipse.core.resources.builders">
<builder
hasNature="true">
- <run class="com.android.ide.eclipse.adt.internal.build.ResourceManagerBuilder"/>
+ <run class="com.android.ide.eclipse.adt.internal.build.builders.ResourceManagerBuilder"/>
</builder>
</extension>
<extension
@@ -56,7 +56,7 @@
point="org.eclipse.core.resources.builders">
<builder
hasNature="true">
- <run class="com.android.ide.eclipse.adt.internal.build.PreCompilerBuilder"/>
+ <run class="com.android.ide.eclipse.adt.internal.build.builders.PreCompilerBuilder"/>
</builder>
</extension>
<extension
@@ -65,7 +65,7 @@
point="org.eclipse.core.resources.builders">
<builder
hasNature="true">
- <run class="com.android.ide.eclipse.adt.internal.build.PostCompilerBuilder"/>
+ <run class="com.android.ide.eclipse.adt.internal.build.builders.PostCompilerBuilder"/>
</builder>
</extension>
<extension
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/AndroidConstants.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/AndroidConstants.java
index e3791ef..21b32ee 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/AndroidConstants.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/AndroidConstants.java
@@ -16,9 +16,9 @@
package com.android.ide.eclipse.adt;
-import com.android.ide.eclipse.adt.internal.build.PostCompilerBuilder;
-import com.android.ide.eclipse.adt.internal.build.PreCompilerBuilder;
-import com.android.ide.eclipse.adt.internal.build.ResourceManagerBuilder;
+import com.android.ide.eclipse.adt.internal.build.builders.PostCompilerBuilder;
+import com.android.ide.eclipse.adt.internal.build.builders.PreCompilerBuilder;
+import com.android.ide.eclipse.adt.internal.build.builders.ResourceManagerBuilder;
import com.android.sdklib.SdkConstants;
import java.io.File;
@@ -178,7 +178,8 @@ public class AndroidConstants {
* from the {@link PreCompilerBuilder} */
public final static String MARKER_ANDROID = LEGACY_PLUGIN_ID + ".androidProblem"; //$NON-NLS-1$
- /** aapt marker error when running the package command, only to be used in {@link PostCompilerBuilder} */
+ /** aapt marker error when running the package command, only to be used in
+ * {@link PostCompilerBuilder} */
public final static String MARKER_AAPT_PACKAGE = LEGACY_PLUGIN_ID + ".aapt2Problem"; //$NON-NLS-1$
/** final packaging error marker, only to be used in {@link PostCompilerBuilder} */
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/actions/MultiApkExportAction.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/actions/MultiApkExportAction.java
index 70e886d..da57a4f 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/actions/MultiApkExportAction.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/actions/MultiApkExportAction.java
@@ -18,7 +18,7 @@ package com.android.ide.eclipse.adt.internal.actions;
import com.android.ide.eclipse.adt.AdtPlugin;
import com.android.ide.eclipse.adt.AndroidPrintStream;
-import com.android.ide.eclipse.adt.internal.build.PostCompilerHelper;
+import com.android.ide.eclipse.adt.internal.build.BuildHelper;
import com.android.ide.eclipse.adt.internal.project.ProjectHelper;
import com.android.ide.eclipse.adt.internal.sdk.ProjectState;
import com.android.ide.eclipse.adt.internal.sdk.Sdk;
@@ -273,7 +273,7 @@ public class MultiApkExportAction implements IObjectActionDelegate {
pkgName += ".ap_";
String outputName = finalNameRoot + "-unsigned.apk";
- PostCompilerHelper helper = new PostCompilerHelper(project, stdout, stderr,
+ BuildHelper helper = new BuildHelper(project, stdout, stderr,
false /*debugMode*/, false/*verbose*/);
// get the manifest file
@@ -295,7 +295,7 @@ public class MultiApkExportAction implements IObjectActionDelegate {
// get the list of referenced projects.
IProject[] javaRefs = ProjectHelper.getReferencedProjects(project);
- IJavaProject[] referencedJavaProjects = PostCompilerHelper.getJavaProjects(javaRefs);
+ IJavaProject[] referencedJavaProjects = BuildHelper.getJavaProjects(javaRefs);
helper.finalPackage(
new File(projectBinFolderPath, pkgName).getAbsolutePath(),
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/AaptExecException.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/AaptExecException.java
new file mode 100644
index 0000000..23b1baa
--- /dev/null
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/AaptExecException.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Eclipse Public License, Version 1.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.eclipse.org/org/documents/epl-v10.php
+ *
+ * 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.android.ide.eclipse.adt.internal.build;
+
+/**
+ * Exception thrown when the execution of aapt fails.
+ *
+ */
+public final class AaptExecException extends Exception {
+ private static final long serialVersionUID = 1L;
+
+ AaptExecException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/AaptParser.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/AaptParser.java
index fd458de..504cf0b 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/AaptParser.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/AaptParser.java
@@ -29,7 +29,7 @@ import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-public class AaptParser {
+public final class AaptParser {
// TODO: rename the pattern to something that makes sense + javadoc comments.
/**
@@ -133,7 +133,7 @@ public class AaptParser {
* @param project the project containing the file to mark
* @return true if the parsing failed, false if success.
*/
- static final boolean parseOutput(List<String> results, IProject project) {
+ public static boolean parseOutput(List<String> results, IProject project) {
return parseOutput(results.toArray(new String[results.size()]), project);
}
@@ -144,7 +144,7 @@ public class AaptParser {
* @param project the project containing the file to mark
* @return true if the parsing failed, false if success.
*/
- static final boolean parseOutput(String[] results, IProject project) {
+ public static boolean parseOutput(String[] results, IProject project) {
// nothing to parse? just return false;
if (results.length == 0) {
return false;
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/AaptResultException.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/AaptResultException.java
new file mode 100644
index 0000000..5a3b53d
--- /dev/null
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/AaptResultException.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Eclipse Public License, Version 1.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.eclipse.org/org/documents/epl-v10.php
+ *
+ * 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.android.ide.eclipse.adt.internal.build;
+
+/**
+ * Exception thrown when aapt reports an error in the resources.
+ *
+ */
+public final class AaptResultException extends Exception {
+ private static final long serialVersionUID = 1L;
+
+ private final int mErrorCode;
+ private final String[] mOutput;
+
+ AaptResultException(int errorCode, String[] output) {
+ mErrorCode = errorCode;
+ mOutput = output;
+ }
+
+ /**
+ * Returns the full output of aapt.
+ */
+ public String[] getOutput() {
+ return mOutput;
+ }
+
+ /**
+ * Returns the aapt return code.
+ */
+ public int getErrorCode() {
+ return mErrorCode;
+ }
+}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/PostCompilerHelper.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/BuildHelper.java
index 928ffac..e67a851 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/PostCompilerHelper.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/BuildHelper.java
@@ -23,7 +23,6 @@ import com.android.ide.eclipse.adt.internal.preferences.AdtPrefs;
import com.android.ide.eclipse.adt.internal.preferences.AdtPrefs.BuildVerbosity;
import com.android.ide.eclipse.adt.internal.project.BaseProjectHelper;
import com.android.ide.eclipse.adt.internal.sdk.AndroidTargetData;
-import com.android.ide.eclipse.adt.internal.sdk.DexWrapper;
import com.android.ide.eclipse.adt.internal.sdk.Sdk;
import com.android.prefs.AndroidLocation.AndroidLocationException;
import com.android.sdklib.IAndroidTarget;
@@ -55,8 +54,10 @@ import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jface.preference.IPreferenceStore;
+import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
+import java.io.InputStreamReader;
import java.io.PrintStream;
import java.security.PrivateKey;
import java.security.cert.X509Certificate;
@@ -84,7 +85,7 @@ import java.util.List;
* to the constructor.
*
*/
-public class PostCompilerHelper {
+public class BuildHelper {
private static final String CONSOLE_PREFIX_DX = "Dx"; //$NON-NLS-1$
@@ -94,74 +95,6 @@ public class PostCompilerHelper {
private final boolean mVerbose;
private final boolean mDebugMode;
- public static final class AaptExecException extends Exception {
- private static final long serialVersionUID = 1L;
-
- AaptExecException(String message, Throwable cause) {
- super(message, cause);
- }
- }
-
- public static final class AaptResultException extends Exception {
- private static final long serialVersionUID = 1L;
-
- private final int mErrorCode;
- private final String[] mOutput;
-
- AaptResultException(int errorCode, String[] output) {
- mErrorCode = errorCode;
- mOutput = output;
- }
-
- public String[] getOutput() {
- return mOutput;
- }
-
- public int getErrorCode() {
- return mErrorCode;
- }
- }
-
- public static final class DexException extends Exception {
- private static final long serialVersionUID = 1L;
-
- DexException(String message) {
- super(message);
- }
-
- DexException(String message, Throwable cause) {
- super(message, cause);
- }
- }
-
- public static final class NativeLibInJarException extends Exception {
- private static final long serialVersionUID = 1L;
-
- private final JarStatus mStatus;
- private final String mLibName;
- private final String[] mConsoleMsgs;
-
- NativeLibInJarException(JarStatus status, String message, String libName,
- String[] consoleMsgs) {
- super(message);
- mStatus = status;
- mLibName = libName;
- mConsoleMsgs = consoleMsgs;
- }
-
- public JarStatus getStatus() {
- return mStatus;
- }
-
- public String getLibName() {
- return mLibName;
- }
-
- public String[] getConsoleMsgs() {
- return mConsoleMsgs;
- }
- }
-
/**
* An object able to put a marker on a resource.
*/
@@ -177,7 +110,7 @@ public class PostCompilerHelper {
* @param debugMode whether this is a debug build
* @param verbose
*/
- public PostCompilerHelper(IProject project, AndroidPrintStream outStream,
+ public BuildHelper(IProject project, AndroidPrintStream outStream,
AndroidPrintStream errStream, boolean debugMode, boolean verbose) {
mProject = project;
mOutStream = outStream;
@@ -576,7 +509,7 @@ public class PostCompilerHelper {
ArrayList<String> results = new ArrayList<String>();
// get the output and return code from the process
- execError = BaseBuilder.grabProcessOutput(mProject, process, results);
+ execError = grabProcessOutput(mProject, process, results);
if (execError != 0) {
throw new AaptResultException(execError,
@@ -763,7 +696,7 @@ public class PostCompilerHelper {
* @param file the IFile representing the file.
* @return true if the file should be packaged as standard java resources.
*/
- static boolean checkFileForPackaging(IFile file) {
+ public static boolean checkFileForPackaging(IFile file) {
String name = file.getName();
String ext = file.getFileExtension();
@@ -775,7 +708,7 @@ public class PostCompilerHelper {
* standard Java resource.
* @param folder the {@link IFolder} to check.
*/
- static boolean checkFolderForPackaging(IFolder folder) {
+ public static boolean checkFolderForPackaging(IFolder folder) {
String name = folder.getName();
return ApkBuilder.checkFolderForPackaging(name);
}
@@ -799,5 +732,70 @@ public class PostCompilerHelper {
return list.toArray(new IJavaProject[list.size()]);
}
+ /**
+ * Get the stderr output of a process and return when the process is done.
+ * @param process The process to get the ouput from
+ * @param results The array to store the stderr output
+ * @return the process return code.
+ * @throws InterruptedException
+ */
+ public final static int grabProcessOutput(final IProject project, final Process process,
+ final ArrayList<String> results)
+ throws InterruptedException {
+ // Due to the limited buffer size on windows for the standard io (stderr, stdout), we
+ // *need* to read both stdout and stderr all the time. If we don't and a process output
+ // a large amount, this could deadlock the process.
+
+ // read the lines as they come. if null is returned, it's
+ // because the process finished
+ new Thread("") { //$NON-NLS-1$
+ @Override
+ public void run() {
+ // create a buffer to read the stderr output
+ InputStreamReader is = new InputStreamReader(process.getErrorStream());
+ BufferedReader errReader = new BufferedReader(is);
+
+ try {
+ while (true) {
+ String line = errReader.readLine();
+ if (line != null) {
+ results.add(line);
+ } else {
+ break;
+ }
+ }
+ } catch (IOException e) {
+ // do nothing.
+ }
+ }
+ }.start();
+
+ new Thread("") { //$NON-NLS-1$
+ @Override
+ public void run() {
+ InputStreamReader is = new InputStreamReader(process.getInputStream());
+ BufferedReader outReader = new BufferedReader(is);
+
+ try {
+ while (true) {
+ String line = outReader.readLine();
+ if (line != null) {
+ AdtPlugin.printBuildToConsole(BuildVerbosity.VERBOSE,
+ project, line);
+ } else {
+ break;
+ }
+ }
+ } catch (IOException e) {
+ // do nothing.
+ }
+ }
+
+ }.start();
+
+ // get the return code from the process
+ return process.waitFor();
+ }
+
}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/DexException.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/DexException.java
new file mode 100644
index 0000000..032e5e6
--- /dev/null
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/DexException.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Eclipse Public License, Version 1.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.eclipse.org/org/documents/epl-v10.php
+ *
+ * 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.android.ide.eclipse.adt.internal.build;
+
+/**
+ * Exception throw when dx fails.
+ *
+ */
+public final class DexException extends Exception {
+ private static final long serialVersionUID = 1L;
+
+ DexException(String message) {
+ super(message);
+ }
+
+ DexException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/sdk/DexWrapper.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/DexWrapper.java
index a5c19c6..db442bf 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/sdk/DexWrapper.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/DexWrapper.java
@@ -14,10 +14,9 @@
* limitations under the License.
*/
-package com.android.ide.eclipse.adt.internal.sdk;
+package com.android.ide.eclipse.adt.internal.build;
import com.android.ide.eclipse.adt.AdtPlugin;
-import com.android.ide.eclipse.adt.internal.build.Messages;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/NativeLibInJarException.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/NativeLibInJarException.java
new file mode 100644
index 0000000..18f4ae7
--- /dev/null
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/NativeLibInJarException.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Eclipse Public License, Version 1.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.eclipse.org/org/documents/epl-v10.php
+ *
+ * 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.android.ide.eclipse.adt.internal.build;
+
+import com.android.sdklib.build.ApkBuilder.JarStatus;
+
+/**
+ * Exception throw when native libraries are detected in jar file.
+ *
+ */
+public final class NativeLibInJarException extends Exception {
+ private static final long serialVersionUID = 1L;
+
+ private final JarStatus mStatus;
+ private final String mLibName;
+ private final String[] mConsoleMsgs;
+
+ NativeLibInJarException(JarStatus status, String message, String libName,
+ String[] consoleMsgs) {
+ super(message);
+ mStatus = status;
+ mLibName = libName;
+ mConsoleMsgs = consoleMsgs;
+ }
+
+ /**
+ * Returns the {@link JarStatus} object containing the information about the libraries that
+ * were found.
+ */
+ public JarStatus getStatus() {
+ return mStatus;
+ }
+
+ /**
+ * Returns the name of the jar file containing the native libraries.
+ */
+ public String getJarName() {
+ return mLibName;
+ }
+
+ /**
+ * Returns additional information that should be shown to the user.
+ */
+ public String[] getAdditionalInfo() {
+ return mConsoleMsgs;
+ }
+}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/BaseBuilder.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/builders/BaseBuilder.java
index 72e09c1..4e9c7f4 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/BaseBuilder.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/builders/BaseBuilder.java
@@ -14,11 +14,12 @@
* limitations under the License.
*/
-package com.android.ide.eclipse.adt.internal.build;
+package com.android.ide.eclipse.adt.internal.build.builders;
import com.android.ide.eclipse.adt.AdtPlugin;
import com.android.ide.eclipse.adt.AndroidConstants;
-import com.android.ide.eclipse.adt.internal.preferences.AdtPrefs.BuildVerbosity;
+import com.android.ide.eclipse.adt.internal.build.BuildHelper;
+import com.android.ide.eclipse.adt.internal.build.Messages;
import com.android.ide.eclipse.adt.internal.project.BaseProjectHelper;
import com.android.ide.eclipse.adt.internal.project.ProjectHelper;
import com.android.ide.eclipse.adt.internal.project.XmlErrorHandler;
@@ -42,9 +43,6 @@ import org.eclipse.core.runtime.Status;
import org.eclipse.jdt.core.IJavaProject;
import org.xml.sax.SAXException;
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
import java.util.ArrayList;
import javax.xml.parsers.ParserConfigurationException;
@@ -250,74 +248,10 @@ abstract class BaseBuilder extends IncrementalProjectBuilder {
*/
protected final int grabProcessOutput(final Process process,
final ArrayList<String> results) throws InterruptedException {
- return grabProcessOutput(getProject(), process, results);
+ return BuildHelper.grabProcessOutput(getProject(), process, results);
}
- /**
- * Get the stderr output of a process and return when the process is done.
- * @param process The process to get the ouput from
- * @param results The array to store the stderr output
- * @return the process return code.
- * @throws InterruptedException
- */
- protected final static int grabProcessOutput(final IProject project, final Process process,
- final ArrayList<String> results)
- throws InterruptedException {
- // Due to the limited buffer size on windows for the standard io (stderr, stdout), we
- // *need* to read both stdout and stderr all the time. If we don't and a process output
- // a large amount, this could deadlock the process.
-
- // read the lines as they come. if null is returned, it's
- // because the process finished
- new Thread("") { //$NON-NLS-1$
- @Override
- public void run() {
- // create a buffer to read the stderr output
- InputStreamReader is = new InputStreamReader(process.getErrorStream());
- BufferedReader errReader = new BufferedReader(is);
-
- try {
- while (true) {
- String line = errReader.readLine();
- if (line != null) {
- results.add(line);
- } else {
- break;
- }
- }
- } catch (IOException e) {
- // do nothing.
- }
- }
- }.start();
-
- new Thread("") { //$NON-NLS-1$
- @Override
- public void run() {
- InputStreamReader is = new InputStreamReader(process.getInputStream());
- BufferedReader outReader = new BufferedReader(is);
-
- try {
- while (true) {
- String line = outReader.readLine();
- if (line != null) {
- AdtPlugin.printBuildToConsole(BuildVerbosity.VERBOSE,
- project, line);
- } else {
- break;
- }
- }
- } catch (IOException e) {
- // do nothing.
- }
- }
-
- }.start();
-
- // get the return code from the process
- return process.waitFor();
- }
/**
* Saves a String property into the persistent storage of the project.
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/LibraryDeltaVisitor.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/builders/LibraryDeltaVisitor.java
index 77d7422..df4c5b9 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/LibraryDeltaVisitor.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/builders/LibraryDeltaVisitor.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.ide.eclipse.adt.internal.build;
+package com.android.ide.eclipse.adt.internal.build.builders;
import com.android.sdklib.SdkConstants;
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/PostCompilerBuilder.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/builders/PostCompilerBuilder.java
index cdea980..622c13d 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/PostCompilerBuilder.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/builders/PostCompilerBuilder.java
@@ -14,16 +14,19 @@
* limitations under the License.
*/
-package com.android.ide.eclipse.adt.internal.build;
+package com.android.ide.eclipse.adt.internal.build.builders;
import com.android.ide.eclipse.adt.AdtPlugin;
import com.android.ide.eclipse.adt.AndroidConstants;
import com.android.ide.eclipse.adt.AndroidPrintStream;
-import com.android.ide.eclipse.adt.internal.build.PostCompilerHelper.AaptExecException;
-import com.android.ide.eclipse.adt.internal.build.PostCompilerHelper.AaptResultException;
-import com.android.ide.eclipse.adt.internal.build.PostCompilerHelper.DexException;
-import com.android.ide.eclipse.adt.internal.build.PostCompilerHelper.NativeLibInJarException;
-import com.android.ide.eclipse.adt.internal.build.PostCompilerHelper.ResourceMarker;
+import com.android.ide.eclipse.adt.internal.build.AaptExecException;
+import com.android.ide.eclipse.adt.internal.build.AaptParser;
+import com.android.ide.eclipse.adt.internal.build.AaptResultException;
+import com.android.ide.eclipse.adt.internal.build.DexException;
+import com.android.ide.eclipse.adt.internal.build.Messages;
+import com.android.ide.eclipse.adt.internal.build.NativeLibInJarException;
+import com.android.ide.eclipse.adt.internal.build.BuildHelper;
+import com.android.ide.eclipse.adt.internal.build.BuildHelper.ResourceMarker;
import com.android.ide.eclipse.adt.internal.preferences.AdtPrefs;
import com.android.ide.eclipse.adt.internal.preferences.AdtPrefs.BuildVerbosity;
import com.android.ide.eclipse.adt.internal.project.ApkInstallManager;
@@ -141,7 +144,7 @@ public class PostCompilerBuilder extends BaseBuilder {
if (type == IResource.FILE) {
// check if the file is a valid file that would be
// included during the final packaging.
- if (PostCompilerHelper.checkFileForPackaging((IFile)resource)) {
+ if (BuildHelper.checkFileForPackaging((IFile)resource)) {
mMakeFinalPackage = true;
}
@@ -150,7 +153,7 @@ public class PostCompilerBuilder extends BaseBuilder {
// if this is a folder, we check if this is a valid folder as well.
// If this is a folder that needs to be ignored, we must return false,
// so that we ignore its content.
- return PostCompilerHelper.checkFolderForPackaging((IFolder)resource);
+ return BuildHelper.checkFolderForPackaging((IFolder)resource);
}
}
}
@@ -226,7 +229,7 @@ public class PostCompilerBuilder extends BaseBuilder {
// get the list of referenced projects.
javaProjects = ProjectHelper.getReferencedProjects(project);
- IJavaProject[] referencedJavaProjects = PostCompilerHelper.getJavaProjects(
+ IJavaProject[] referencedJavaProjects = BuildHelper.getJavaProjects(
javaProjects);
// mix the java project and the library projects
@@ -406,7 +409,7 @@ public class PostCompilerBuilder extends BaseBuilder {
// we need to test all three, as we may need to make the final package
// but not the intermediary ones.
if (mPackageResources || mConvertToDex || mBuildFinalPackage) {
- PostCompilerHelper helper = new PostCompilerHelper(project,
+ BuildHelper helper = new BuildHelper(project,
mOutStream, mErrStream,
true /*debugMode*/,
AdtPrefs.getPrefs().getBuildVerbosity() == BuildVerbosity.VERBOSE);
@@ -560,7 +563,7 @@ public class PostCompilerBuilder extends BaseBuilder {
BaseProjectHelper.markResource(project, AndroidConstants.MARKER_PACKAGING,
msg, IMarker.SEVERITY_ERROR);
- AdtPlugin.printErrorToConsole(project, (Object[]) e.getConsoleMsgs());
+ AdtPlugin.printErrorToConsole(project, (Object[]) e.getAdditionalInfo());
} catch (CoreException e) {
// mark project and return
String msg = String.format(Messages.Final_Archive_Error_s, e.getMessage());
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/PostCompilerDeltaVisitor.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/builders/PostCompilerDeltaVisitor.java
index 269535b..eaa1722 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/PostCompilerDeltaVisitor.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/builders/PostCompilerDeltaVisitor.java
@@ -14,10 +14,11 @@
* limitations under the License.
*/
-package com.android.ide.eclipse.adt.internal.build;
+package com.android.ide.eclipse.adt.internal.build.builders;
import com.android.ide.eclipse.adt.AndroidConstants;
-import com.android.ide.eclipse.adt.internal.build.BaseBuilder.BaseDeltaVisitor;
+import com.android.ide.eclipse.adt.internal.build.BuildHelper;
+import com.android.ide.eclipse.adt.internal.build.builders.BaseBuilder.BaseDeltaVisitor;
import com.android.sdklib.SdkConstants;
import org.eclipse.core.resources.IFile;
@@ -260,9 +261,9 @@ public class PostCompilerDeltaVisitor extends BaseDeltaVisitor
// Also excluded are aidl files, and package.html files
if (type == IResource.FOLDER) {
// always visit the subfolders, unless the folder is not to be included
- return PostCompilerHelper.checkFolderForPackaging((IFolder)resource);
+ return BuildHelper.checkFolderForPackaging((IFolder)resource);
} else if (type == IResource.FILE) {
- if (PostCompilerHelper.checkFileForPackaging((IFile)resource)) {
+ if (BuildHelper.checkFileForPackaging((IFile)resource)) {
mMakeFinalPackage = true;
}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/PreCompilerBuilder.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/builders/PreCompilerBuilder.java
index c50244d..ee9c749 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/PreCompilerBuilder.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/builders/PreCompilerBuilder.java
@@ -14,10 +14,12 @@
* limitations under the License.
*/
-package com.android.ide.eclipse.adt.internal.build;
+package com.android.ide.eclipse.adt.internal.build.builders;
import com.android.ide.eclipse.adt.AdtPlugin;
import com.android.ide.eclipse.adt.AndroidConstants;
+import com.android.ide.eclipse.adt.internal.build.AaptParser;
+import com.android.ide.eclipse.adt.internal.build.Messages;
import com.android.ide.eclipse.adt.internal.preferences.AdtPrefs;
import com.android.ide.eclipse.adt.internal.preferences.AdtPrefs.BuildVerbosity;
import com.android.ide.eclipse.adt.internal.project.AndroidManifestHelper;
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/PreCompilerDeltaVisitor.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/builders/PreCompilerDeltaVisitor.java
index 3d7a7d8..4776666 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/PreCompilerDeltaVisitor.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/builders/PreCompilerDeltaVisitor.java
@@ -14,12 +14,13 @@
* limitations under the License.
*/
-package com.android.ide.eclipse.adt.internal.build;
+package com.android.ide.eclipse.adt.internal.build.builders;
import com.android.ide.eclipse.adt.AdtPlugin;
import com.android.ide.eclipse.adt.AndroidConstants;
-import com.android.ide.eclipse.adt.internal.build.BaseBuilder.BaseDeltaVisitor;
-import com.android.ide.eclipse.adt.internal.build.PreCompilerBuilder.AidlData;
+import com.android.ide.eclipse.adt.internal.build.Messages;
+import com.android.ide.eclipse.adt.internal.build.builders.BaseBuilder.BaseDeltaVisitor;
+import com.android.ide.eclipse.adt.internal.build.builders.PreCompilerBuilder.AidlData;
import com.android.ide.eclipse.adt.internal.preferences.AdtPrefs.BuildVerbosity;
import com.android.ide.eclipse.adt.internal.project.AndroidManifestHelper;
import com.android.ide.eclipse.adt.io.IFileWrapper;
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/ResourceManagerBuilder.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/builders/ResourceManagerBuilder.java
index 871b4b8..c8670b4 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/ResourceManagerBuilder.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/builders/ResourceManagerBuilder.java
@@ -14,10 +14,11 @@
* limitations under the License.
*/
-package com.android.ide.eclipse.adt.internal.build;
+package com.android.ide.eclipse.adt.internal.build.builders;
import com.android.ide.eclipse.adt.AdtPlugin;
import com.android.ide.eclipse.adt.AndroidConstants;
+import com.android.ide.eclipse.adt.internal.build.Messages;
import com.android.ide.eclipse.adt.internal.preferences.AdtPrefs;
import com.android.ide.eclipse.adt.internal.preferences.AdtPrefs.BuildVerbosity;
import com.android.ide.eclipse.adt.internal.project.BaseProjectHelper;
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/AndroidNature.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/AndroidNature.java
index 8281639..5e05c99 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/AndroidNature.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/AndroidNature.java
@@ -17,9 +17,9 @@
package com.android.ide.eclipse.adt.internal.project;
import com.android.ide.eclipse.adt.AndroidConstants;
-import com.android.ide.eclipse.adt.internal.build.PostCompilerBuilder;
-import com.android.ide.eclipse.adt.internal.build.PreCompilerBuilder;
-import com.android.ide.eclipse.adt.internal.build.ResourceManagerBuilder;
+import com.android.ide.eclipse.adt.internal.build.builders.PostCompilerBuilder;
+import com.android.ide.eclipse.adt.internal.build.builders.PreCompilerBuilder;
+import com.android.ide.eclipse.adt.internal.build.builders.ResourceManagerBuilder;
import org.eclipse.core.resources.ICommand;
import org.eclipse.core.resources.IProject;
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/ExportHelper.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/ExportHelper.java
index 2a10fb8..9cdc5a0 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/ExportHelper.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/ExportHelper.java
@@ -19,7 +19,7 @@ package com.android.ide.eclipse.adt.internal.project;
import com.android.ide.eclipse.adt.AdtPlugin;
import com.android.ide.eclipse.adt.AndroidConstants;
import com.android.ide.eclipse.adt.AndroidPrintStream;
-import com.android.ide.eclipse.adt.internal.build.PostCompilerHelper;
+import com.android.ide.eclipse.adt.internal.build.BuildHelper;
import com.android.ide.eclipse.adt.internal.sdk.ProjectState;
import com.android.ide.eclipse.adt.internal.sdk.Sdk;
import com.android.sdklib.SdkConstants;
@@ -82,7 +82,7 @@ public final class ExportHelper {
}
});
- PostCompilerHelper helper = new PostCompilerHelper(project,
+ BuildHelper helper = new BuildHelper(project,
fakeStream, fakeStream,
false /*debugMode*/, false /*verbose*/);
@@ -114,7 +114,7 @@ public final class ExportHelper {
IJavaProject javaProject = JavaCore.create(project);
IProject[] javaProjects = ProjectHelper.getReferencedProjects(project);
- IJavaProject[] referencedJavaProjects = PostCompilerHelper.getJavaProjects(
+ IJavaProject[] referencedJavaProjects = BuildHelper.getJavaProjects(
javaProjects);
helper.executeDx(
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/sdk/AndroidTargetData.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/sdk/AndroidTargetData.java
index dd1f054..765dfbb 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/sdk/AndroidTargetData.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/sdk/AndroidTargetData.java
@@ -17,6 +17,7 @@
package com.android.ide.eclipse.adt.internal.sdk;
import com.android.ide.eclipse.adt.AdtPlugin;
+import com.android.ide.eclipse.adt.internal.build.DexWrapper;
import com.android.ide.eclipse.adt.internal.editors.descriptors.IDescriptorProvider;
import com.android.ide.eclipse.adt.internal.editors.layout.descriptors.LayoutDescriptors;
import com.android.ide.eclipse.adt.internal.editors.manifest.descriptors.AndroidManifestDescriptors;
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/sdk/AndroidTargetParser.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/sdk/AndroidTargetParser.java
index 4bbad4f..fb19fc8 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/sdk/AndroidTargetParser.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/sdk/AndroidTargetParser.java
@@ -18,6 +18,7 @@ package com.android.ide.eclipse.adt.internal.sdk;
import com.android.ide.eclipse.adt.AdtPlugin;
import com.android.ide.eclipse.adt.AndroidConstants;
+import com.android.ide.eclipse.adt.internal.build.DexWrapper;
import com.android.ide.eclipse.adt.internal.editors.layout.descriptors.LayoutDescriptors;
import com.android.ide.eclipse.adt.internal.editors.manifest.descriptors.AndroidManifestDescriptors;
import com.android.ide.eclipse.adt.internal.editors.menu.descriptors.MenuDescriptors;