aboutsummaryrefslogtreecommitdiffstats
path: root/eclipse/plugins
diff options
context:
space:
mode:
authorXavier Ducrohet <xav@android.com>2013-02-01 14:47:50 -0800
committerXavier Ducrohet <xav@android.com>2013-02-01 14:47:50 -0800
commite9310ad46b41f082518159bdab7a3a722f3f6216 (patch)
tree108c4e92b4ebb9a2d4a8051254e9c3fec28f8e38 /eclipse/plugins
parent641afb8bbfa8bc8e980808c22a3e9ecb45008a3c (diff)
downloadsdk-e9310ad46b41f082518159bdab7a3a722f3f6216.zip
sdk-e9310ad46b41f082518159bdab7a3a722f3f6216.tar.gz
sdk-e9310ad46b41f082518159bdab7a3a722f3f6216.tar.bz2
Fix generation of R classes for libraries to support any package name.
Change-Id: I0e4f2c0d56285b911f0210a3cddbed0f5ec05ecc
Diffstat (limited to 'eclipse/plugins')
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/META-INF/MANIFEST.MF6
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/builders/PreCompilerBuilder.java116
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.ndk/.classpath2
3 files changed, 39 insertions, 85 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/META-INF/MANIFEST.MF b/eclipse/plugins/com.android.ide.eclipse.adt/META-INF/MANIFEST.MF
index 262da58..7cdb400 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/META-INF/MANIFEST.MF
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/META-INF/MANIFEST.MF
@@ -58,7 +58,6 @@ Export-Package: com.android.assetstudiolib;x-friends:="com.android.ide.eclipse.t
com.android.ide.common.layout;x-friends:="com.android.ide.eclipse.tests",
com.android.ide.common.layout.grid;x-friends:="com.android.ide.eclipse.tests",
com.android.ide.common.layout.relative;x-friends:="com.android.ide.eclipse.tests",
- com.android.ide.common.rendering.api;x-friends:="com.android.ide.eclipse.tests",
com.android.ide.common.resources.platform;x-friends:="com.android.ide.eclipse.tests",
com.android.ide.eclipse.adt;x-friends:="com.android.ide.eclipse.tests",
com.android.ide.eclipse.adt.internal;x-friends:="com.android.ide.eclipse.tests",
@@ -112,6 +111,7 @@ Export-Package: com.android.assetstudiolib;x-friends:="com.android.ide.eclipse.t
com.android.ide.eclipse.adt.internal.sdk;x-friends:="com.android.ide.eclipse.tests",
com.android.ide.eclipse.adt.internal.sourcelookup;x-friends:="com.android.ide.eclipse.tests",
com.android.ide.eclipse.adt.internal.ui;x-friends:="com.android.ide.eclipse.tests",
+ com.android.ide.eclipse.adt.internal.utils;x-friends:="com.android.ide.eclipse.tests",
com.android.ide.eclipse.adt.internal.welcome;x-friends:="com.android.ide.eclipse.tests",
com.android.ide.eclipse.adt.internal.wizards.actions;x-friends:="com.android.ide.eclipse.tests",
com.android.ide.eclipse.adt.internal.wizards.export;x-friends:="com.android.ide.eclipse.tests",
@@ -119,11 +119,8 @@ Export-Package: com.android.assetstudiolib;x-friends:="com.android.ide.eclipse.t
com.android.ide.eclipse.adt.internal.wizards.newxmlfile;x-friends:="com.android.ide.eclipse.tests",
com.android.ide.eclipse.adt.internal.wizards.templates;x-friends:="com.android.ide.eclipse.tests",
com.android.ide.eclipse.adt.io;x-friends:="com.android.ide.eclipse.tests",
- com.android.layoutlib.api;x-friends:="com.android.ide.eclipse.tests",
com.android.manifmerger;x-friends:="com.android.ide.eclipse.tests",
- com.android.menubar;x-friends:="com.android.ide.eclipse.tests",
com.android.ninepatch;x-friends:="com.android.ide.eclipse.tests",
- com.android.resources;x-friends:="com.android.ide.eclipse.tests",
com.android.sdkuilib.internal.repository;x-friends:="com.android.ide.eclipse.tests",
com.android.sdkuilib.internal.repository.core;x-friends:="com.android.ide.eclipse.tests",
com.android.sdkuilib.internal.repository.icons;x-friends:="com.android.ide.eclipse.tests",
@@ -135,7 +132,6 @@ Export-Package: com.android.assetstudiolib;x-friends:="com.android.ide.eclipse.t
com.android.tools.lint.checks;x-friends:="com.android.ide.eclipse.tests",
com.android.tools.lint.client.api;x-friends:="com.android.ide.eclipse.tests",
com.android.tools.lint.detector.api;x-friends:="com.android.ide.eclipse.tests",
- com.android.util;x-friends:="com.android.ide.eclipse.tests",
freemarker.cache;x-friends:="com.android.ide.eclipse.tests",
freemarker.template;x-friends:="com.android.ide.eclipse.tests",
org.kxml2.io;x-friends:="com.android.ide.eclipse.tests",
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/builders/PreCompilerBuilder.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/builders/PreCompilerBuilder.java
index ba23c95..a85bfd5 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/builders/PreCompilerBuilder.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/builders/PreCompilerBuilder.java
@@ -55,9 +55,9 @@ import com.android.sdklib.io.FileOp;
import com.android.utils.ILogger;
import com.android.utils.Pair;
import com.android.xml.AndroidManifest;
+import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
+import com.google.common.collect.Multimap;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
@@ -78,9 +78,9 @@ import org.xml.sax.SAXException;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.List;
import java.util.Map;
-import java.util.Set;
import javax.xml.parsers.ParserConfigurationException;
@@ -94,6 +94,7 @@ import javax.xml.parsers.ParserConfigurationException;
* </ul>
*
*/
+@SuppressWarnings("deprecation")
public class PreCompilerBuilder extends BaseBuilder {
/** This ID is used in plugin.xml and in each project's .project file.
@@ -806,6 +807,7 @@ public class PreCompilerBuilder extends BaseBuilder {
}
}
+ @SuppressWarnings("deprecation")
private void handleBuildConfig(@SuppressWarnings("rawtypes") Map args)
throws IOException, CoreException {
boolean debugMode = !args.containsKey(RELEASE_REQUESTED);
@@ -1034,6 +1036,7 @@ public class PreCompilerBuilder extends BaseBuilder {
* @param proguardFile an optional path to store proguard information
* @throws AbortBuildException
*/
+ @SuppressWarnings("deprecation")
private void execAapt(IProject project, IAndroidTarget projectTarget, String osOutputPath,
String osResPath, String osManifestPath, IFolder packageFolder,
ArrayList<IFolder> libResFolders, List<Pair<File, String>> libRFiles,
@@ -1049,7 +1052,6 @@ public class PreCompilerBuilder extends BaseBuilder {
// launch aapt: create the command line
ArrayList<String> array = new ArrayList<String>();
- @SuppressWarnings("deprecation")
String aaptPath = projectTarget.getPath(IAndroidTarget.AAPT);
array.add(aaptPath);
@@ -1160,71 +1162,40 @@ public class PreCompilerBuilder extends BaseBuilder {
// if the project has no resources, the file could not exist.
if (rFile.isFile()) {
// Load the full symbols from the full R.txt file.
- SymbolLoader fullSymbols = new SymbolLoader(rFile);
- fullSymbols.load();
-
- // simpler case of a single library
- if (libRFiles.size() == 1) {
- Pair<File, String> lib = libRFiles.get(0);
- createRClass(fullSymbols, lib.getFirst(), lib.getSecond(), osOutputPath);
-
- } else {
- Map<String, File> libPackages = Maps.newHashMapWithExpectedSize(
- libRFiles.size());
- Set<String> duplicatePackages = Sets.newHashSet();
-
- // preprocessing to figure out if there are dups in the package names of
- // the libraries
- for (Pair<File, String> lib : libRFiles) {
- String libPackage = lib.getSecond();
- File existingPkg = libPackages.get(libPackage);
- if (existingPkg != null) {
- // record the dup package and keep going, in case there are all
- // the same
- duplicatePackages.add(libPackage);
- continue;
- }
-
- libPackages.put(libPackage, lib.getFirst());
+ SymbolLoader fullSymbolValues = new SymbolLoader(rFile);
+ fullSymbolValues.load();
+
+ Multimap<String, SymbolLoader> libMap = ArrayListMultimap.create();
+
+ // First pass processing the libraries, collecting them by packageName,
+ // and ignoring the ones that have the same package name as the application
+ // (since that R class was already created).
+
+ for (Pair<File, String> lib : libRFiles) {
+ String libPackage = lib.getSecond();
+ File rText = lib.getFirst();
+
+ if (rText.isFile()) {
+ // load the lib symbols
+ SymbolLoader libSymbols = new SymbolLoader(rText);
+ libSymbols.load();
+
+ // store these symbols by associating them with the package name.
+ libMap.put(libPackage, libSymbols);
}
+ }
- // check if we have duplicate but all files are the same.
- if (duplicatePackages.size() > 0) {
- // possible conflict!
- // detect case of all libraries == same package.
- if (duplicatePackages.size() == 1 && libPackages.size() == 1 &&
- duplicatePackages.iterator().next().equals(libPackages.keySet().iterator().next())) {
- // this is ok, all libraries have the same package.
- // Make a copy of the full R class.
- SymbolWriter writer = new SymbolWriter(osOutputPath,
- duplicatePackages.iterator().next(),
- fullSymbols, fullSymbols);
- writer.write();
- } else {
- StringBuilder sb = new StringBuilder();
- sb.append("The following packages have been found to be used by two or more libraries:");
- for (String pkg : duplicatePackages) {
- sb.append("\n\t").append(pkg);
- }
- sb.append("\nNo libraries must share the same package, unless all libraries share the same packages.");
-
- String msg = sb.toString();
- markProject(AdtConstants.MARKER_ADT, msg, IMarker.SEVERITY_ERROR);
-
- AdtPlugin.printBuildToConsole(BuildVerbosity.VERBOSE, project,
- msg);
-
- throw new AbortBuildException();
- }
- } else {
- // no dups, all libraries have different packages.
- // Conflicts with the main package have been removed already.
- // Just process all the libraries.
- for (Pair<File, String> lib : libRFiles) {
- createRClass(fullSymbols, lib.getFirst(), lib.getSecond(),
- osOutputPath);
- }
+ // now loop on all the package names, merge all the symbols to write,
+ // and write them
+ for (String packageName : libMap.keySet()) {
+ Collection<SymbolLoader> symbols = libMap.get(packageName);
+
+ SymbolWriter writer = new SymbolWriter(osOutputPath, packageName,
+ fullSymbolValues);
+ for (SymbolLoader symbolLoader : symbols) {
+ writer.addSymbolsToWrite(symbolLoader);
}
+ writer.write();
}
}
}
@@ -1283,19 +1254,6 @@ public class PreCompilerBuilder extends BaseBuilder {
}
}
- private void createRClass(SymbolLoader fullSymbols, File libRTxtFile, String libPackage,
- String osOutputPath) throws IOException {
- if (libRTxtFile.isFile()) {
- SymbolLoader libSymbols = new SymbolLoader(libRTxtFile);
- libSymbols.load();
-
- SymbolWriter writer = new SymbolWriter(osOutputPath, libPackage, libSymbols,
- fullSymbols);
- writer.write();
- }
- }
-
-
/**
* Creates a relative {@link IPath} from a java package.
* @param javaPackageName the java package.
diff --git a/eclipse/plugins/com.android.ide.eclipse.ndk/.classpath b/eclipse/plugins/com.android.ide.eclipse.ndk/.classpath
index d37aeb2..58a22d6 100644
--- a/eclipse/plugins/com.android.ide.eclipse.ndk/.classpath
+++ b/eclipse/plugins/com.android.ide.eclipse.ndk/.classpath
@@ -5,6 +5,6 @@
<classpathentry kind="src" path="src"/>
<classpathentry combineaccessrules="false" kind="src" path="/ddmlib"/>
<classpathentry combineaccessrules="false" kind="src" path="/ddmuilib"/>
- <classpathentry combineaccessrules="false" kind="src" path="/SdkLib"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/sdklib"/>
<classpathentry kind="output" path="bin"/>
</classpath>