Android runtime module extracted

This commit is contained in:
Roman Shevchenko
2012-03-21 21:23:53 +01:00
parent accd15a275
commit ecc20ea2f4
26 changed files with 270 additions and 101 deletions
+1
View File
@@ -10,6 +10,7 @@
<module fileurl="file://$PROJECT_DIR$/plugins/IntentionPowerPak/IntentionPowerPackPlugin.iml" filepath="$PROJECT_DIR$/plugins/IntentionPowerPak/IntentionPowerPackPlugin.iml" group="plugins" />
<module fileurl="file://$PROJECT_DIR$/RegExpSupport/RegExpSupport.iml" filepath="$PROJECT_DIR$/RegExpSupport/RegExpSupport.iml" />
<module fileurl="file://$PROJECT_DIR$/plugins/android/android.iml" filepath="$PROJECT_DIR$/plugins/android/android.iml" group="plugins/Android" />
<module fileurl="file://$PROJECT_DIR$/plugins/android/common/android-common.iml" filepath="$PROJECT_DIR$/plugins/android/common/android-common.iml" group="plugins/Android" />
<module fileurl="file://$PROJECT_DIR$/plugins/android/jps-plugin/android-jps-plugin.iml" filepath="$PROJECT_DIR$/plugins/android/jps-plugin/android-jps-plugin.iml" group="plugins/Android" />
<module fileurl="file://$PROJECT_DIR$/plugins/android/rt/android-rt.iml" filepath="$PROJECT_DIR$/plugins/android/rt/android-rt.iml" group="plugins/Android" />
<module fileurl="file://$PROJECT_DIR$/platform/annotations/annotations.iml" filepath="$PROJECT_DIR$/platform/annotations/annotations.iml" group="platform" />
+4 -1
View File
@@ -383,7 +383,10 @@ public def layoutCommunityPlugins(String home) {
exclude(name: "**/ddmlib_1.jar")
}
jar("android_rt.jar") {module("android-rt")}
jar("android-common.jar") {
module("android-rt")
module("android-common")
}
dir("jps") {
jar("android-jps-plugin.jar") { module("android-jps-plugin") }
@@ -44,6 +44,90 @@ public class FileUtilRt {
private static String ourCanonicalTempPathCache = null;
@NotNull
public static String getExtension(@NotNull String fileName) {
int index = fileName.lastIndexOf('.');
if (index < 0) return "";
return fileName.substring(index + 1).toLowerCase();
}
@NotNull
public static String toSystemDependentName(@NonNls @NotNull String aFileName) {
return aFileName.replace('/', File.separatorChar).replace('\\', File.separatorChar);
}
@NotNull
public static String toSystemIndependentName(@NonNls @NotNull String aFileName) {
return aFileName.replace('\\', '/');
}
@Nullable
public static String getRelativePath(File base, File file) {
if (base == null || file == null) return null;
if (!base.isDirectory()) {
base = base.getParentFile();
if (base == null) return null;
}
if (base.equals(file)) return ".";
final String filePath = file.getAbsolutePath();
String basePath = base.getAbsolutePath();
return getRelativePath(basePath, filePath, File.separatorChar);
}
@Nullable
public static String getRelativePath(@NotNull String basePath, @NotNull String filePath, final char separator) {
return getRelativePath(basePath, filePath, separator, SystemInfoRt.isFileSystemCaseSensitive);
}
@Nullable
public static String getRelativePath(@NotNull String basePath,
@NotNull String filePath,
final char separator,
final boolean caseSensitive) {
basePath = ensureEnds(basePath, separator);
String basePathToCompare = caseSensitive ? basePath : basePath.toLowerCase();
String filePathToCompare = caseSensitive ? filePath : filePath.toLowerCase();
if (basePathToCompare.equals(ensureEnds(filePathToCompare, separator))) return ".";
int len = 0;
int lastSeparatorIndex = 0; // need this for cases like this: base="/temp/abcde/base" and file="/temp/ab"
while (len < filePath.length() && len < basePath.length() && filePathToCompare.charAt(len) == basePathToCompare.charAt(len)) {
if (basePath.charAt(len) == separator) {
lastSeparatorIndex = len;
}
len++;
}
if (len == 0) return null;
StringBuilder relativePath = new StringBuilder();
for (int i = len; i < basePath.length(); i++) {
if (basePath.charAt(i) == separator) {
relativePath.append("..");
relativePath.append(separator);
}
}
relativePath.append(filePath.substring(lastSeparatorIndex + 1));
return relativePath.toString();
}
private static String ensureEnds(@NotNull String s, final char endsWith) {
return StringUtilRt.endsWithChar(s, endsWith) ? s : s + endsWith;
}
@NotNull
public static String getNameWithoutExtension(@NotNull String name) {
int i = name.lastIndexOf('.');
if (i != -1) {
name = name.substring(0, i);
}
return name;
}
@NotNull
public static File createTempDirectory(@NotNull @NonNls String prefix, @Nullable @NonNls String suffix) throws IOException {
File file = doCreateTempFile(prefix, suffix);
@@ -186,4 +186,8 @@ public class StringUtilRt {
}
return fqName;
}
public static boolean endsWithChar(@Nullable CharSequence s, char suffix) {
return s != null && s.length() != 0 && s.charAt(s.length() - 1) == suffix;
}
}
@@ -64,58 +64,20 @@ public class FileUtil extends FileUtilRt {
@Nullable
public static String getRelativePath(File base, File file) {
if (base == null || file == null) return null;
if (!base.isDirectory()) {
base = base.getParentFile();
if (base == null) return null;
}
if (base.equals(file)) return ".";
final String filePath = file.getAbsolutePath();
String basePath = base.getAbsolutePath();
return getRelativePath(basePath, filePath, File.separatorChar);
return FileUtilRt.getRelativePath(base, file);
}
@Nullable
public static String getRelativePath(@NotNull String basePath, @NotNull String filePath, final char separator) {
return getRelativePath(basePath, filePath, separator, SystemInfo.isFileSystemCaseSensitive);
}
private static String ensureEnds(@NotNull String s, final char endsWith) {
return StringUtil.endsWithChar(s, endsWith) ? s : s + endsWith;
return FileUtilRt.getRelativePath(basePath, filePath, separator);
}
@Nullable
public static String getRelativePath(@NotNull String basePath,
@NotNull String filePath,
final char separator,
final boolean caseSensitive) {
basePath = ensureEnds(basePath, separator);
String basePathToCompare = caseSensitive ? basePath : basePath.toLowerCase();
String filePathToCompare = caseSensitive ? filePath : filePath.toLowerCase();
if (basePathToCompare.equals(ensureEnds(filePathToCompare, separator))) return ".";
int len = 0;
int lastSeparatorIndex = 0; // need this for cases like this: base="/temp/abcde/base" and file="/temp/ab"
while (len < filePath.length() && len < basePath.length() && filePathToCompare.charAt(len) == basePathToCompare.charAt(len)) {
if (basePath.charAt(len) == separator) {
lastSeparatorIndex = len;
}
len++;
}
if (len == 0) return null;
StringBuilder relativePath = new StringBuilder();
for (int i = len; i < basePath.length(); i++) {
if (basePath.charAt(i) == separator) {
relativePath.append("..");
relativePath.append(separator);
}
}
relativePath.append(filePath.substring(lastSeparatorIndex + 1));
return relativePath.toString();
return FileUtilRt.getRelativePath(basePath, filePath, separator, caseSensitive);
}
public static boolean isAbsolute(@NotNull String path) {
@@ -597,11 +559,7 @@ public class FileUtil extends FileUtilRt {
@NotNull
public static String getNameWithoutExtension(@NotNull String name) {
int i = name.lastIndexOf('.');
if (i != -1) {
name = name.substring(0, i);
}
return name;
return FileUtilRt.getNameWithoutExtension(name);
}
public static String createSequentFileName(@NotNull File aParentFolder, @NotNull @NonNls String aFilePrefix, @NotNull String aExtension) {
@@ -624,12 +582,12 @@ public class FileUtil extends FileUtilRt {
@NotNull
public static String toSystemDependentName(@NonNls @NotNull String aFileName) {
return aFileName.replace('/', File.separatorChar).replace('\\', File.separatorChar);
return FileUtilRt.toSystemDependentName(aFileName);
}
@NotNull
public static String toSystemIndependentName(@NonNls @NotNull String aFileName) {
return aFileName.replace('\\', '/');
return FileUtilRt.toSystemIndependentName(aFileName);
}
@NotNull
@@ -738,9 +696,7 @@ public class FileUtil extends FileUtilRt {
@NotNull
public static String getExtension(@NotNull String fileName) {
int index = fileName.lastIndexOf('.');
if (index < 0) return "";
return fileName.substring(index + 1).toLowerCase();
return FileUtilRt.getExtension(fileName);
}
@NotNull
@@ -803,7 +803,7 @@ public class StringUtil extends StringUtilRt {
}
public static boolean endsWithChar(@Nullable CharSequence s, char suffix) {
return s != null && s.length() != 0 && s.charAt(s.length() - 1) == suffix;
return StringUtilRt.endsWithChar(s, suffix);
}
@NotNull
+1
View File
@@ -62,6 +62,7 @@
<orderEntry type="library" name="xpp3-1.1.4-min" level="project" />
<orderEntry type="module" module-name="IntentionPowerPackPlugin" />
<orderEntry type="module" module-name="testng" />
<orderEntry type="module" module-name="android-common" />
<orderEntry type="module" module-name="android-rt" />
</component>
</module>
+32
View File
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/../rt/resources" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="util" />
<orderEntry type="module-library" exported="">
<library name="android-sdk-tools-jps">
<CLASSES>
<root url="jar://$MODULE_DIR$/../lib/sdklib.jar!/" />
<root url="jar://$MODULE_DIR$/../lib/common.jar!/" />
<root url="jar://$MODULE_DIR$/../lib/jarutils.jar!/" />
<root url="jar://$MODULE_DIR$/../lib/androidprefs.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$MODULE_DIR$/../lib/src/sdklib_src.zip!/src" />
<root url="jar://$MODULE_DIR$/../lib/src/common_src.zip!/src" />
<root url="jar://$MODULE_DIR$/../lib/src/jarutils.zip!/src" />
<root url="jar://$MODULE_DIR$/../lib/src/androidprefs_src.zip!/src" />
</SOURCES>
</library>
</orderEntry>
<orderEntry type="library" name="NanoXML" level="project" />
</component>
</module>
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2010 JetBrains s.r.o.
* Copyright 2000-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2010 JetBrains s.r.o.
* Copyright 2000-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2010 JetBrains s.r.o.
* Copyright 2000-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1,3 +1,18 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
*
* 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 org.jetbrains.android.compiler.tools;
import com.android.sdklib.IAndroidTarget;
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2010 JetBrains s.r.o.
* Copyright 2000-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1,3 +1,18 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
*
* 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 org.jetbrains.android.util;
import com.android.resources.ResourceFolderType;
@@ -0,0 +1,23 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
*
* 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 org.jetbrains.android.util;
/**
* @author Eugene.Kudelevsky
*/
public enum AndroidCompilerMessageKind {
ERROR, INFORMATION, WARNING
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2010 JetBrains s.r.o.
* Copyright 2000-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1,3 +1,18 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
*
* 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 org.jetbrains.android.util;
import com.intellij.execution.process.BaseOSProcessHandler;
@@ -1,3 +1,18 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
*
* 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 org.jetbrains.android.util;
import org.jetbrains.annotations.NotNull;
@@ -1,3 +1,18 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
*
* 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 org.jetbrains.android.util;
import com.android.resources.ResourceType;
@@ -9,6 +9,7 @@
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Groovy" level="project" />
<orderEntry type="module" module-name="jps-model" />
<orderEntry type="module" module-name="android-common" />
<orderEntry type="module" module-name="android-rt" />
<orderEntry type="module" module-name="jps-builders" />
<orderEntry type="module" module-name="util" />
@@ -1,9 +1,25 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
*
* 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 org.jetbrains.jps.android;
import com.android.sdklib.IAndroidTarget;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.io.FileUtilRt;
import com.intellij.util.ArrayUtil;
import com.intellij.util.containers.HashMap;
import com.intellij.util.containers.HashSet;
@@ -217,7 +233,7 @@ public class AndroidDexBuilder extends ProjectLevelBuilder {
final List<String> classPath = new ArrayList<String>();
classPath.add(ClasspathBootstrap.getResourcePath(AndroidDxRunner.class).getPath());
classPath.add(ClasspathBootstrap.getResourcePath(FileUtil.class).getPath());
classPath.add(ClasspathBootstrap.getResourcePath(FileUtilRt.class).getPath());
final File outFile = new File(outFilePath);
if (outFile.exists() && !outFile.delete()) {
+2 -20
View File
@@ -4,29 +4,11 @@
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/resources" isTestSource="false" />
</content>
<orderEntry type="module" module-name="util" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module-library" exported="">
<library name="android-sdk-tools-jps">
<CLASSES>
<root url="jar://$MODULE_DIR$/../lib/sdklib.jar!/" />
<root url="jar://$MODULE_DIR$/../lib/common.jar!/" />
<root url="jar://$MODULE_DIR$/../lib/jarutils.jar!/" />
<root url="jar://$MODULE_DIR$/../lib/androidprefs.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$MODULE_DIR$/../lib/src/sdklib_src.zip!/src" />
<root url="jar://$MODULE_DIR$/../lib/src/common_src.zip!/src" />
<root url="jar://$MODULE_DIR$/../lib/src/jarutils.zip!/src" />
<root url="jar://$MODULE_DIR$/../lib/src/androidprefs_src.zip!/src" />
</SOURCES>
</library>
</orderEntry>
<orderEntry type="library" name="NanoXML" level="project" />
<orderEntry type="module" module-name="annotations" />
<orderEntry type="module" module-name="util-rt" />
</component>
</module>
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2010 JetBrains s.r.o.
* Copyright 2000-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
*/
package org.jetbrains.android.compiler.tools;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.io.FileUtilRt;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.Nullable;
@@ -56,8 +56,7 @@ public class AndroidDxRunner {
private static Field myConsoleOut;
private static Field myConsoleErr;
private AndroidDxRunner() {
}
private AndroidDxRunner() { }
private static void loadDex(String dxPath) {
try {
@@ -166,10 +165,10 @@ public class AndroidDxRunner {
}
}
else {
if ("class".equals(FileUtil.getExtension(file.getName()))) {
if ("class".equals(FileUtilRt.getExtension(file.getName()))) {
final String qName = getQualifiedName(root, file);
if (qName != null && !qNames.add(qName)) {
reportWarning(FileUtil.toSystemDependentName(file.getPath()) + " won't be added. Class " +
reportWarning(FileUtilRt.toSystemDependentName(file.getPath()) + " won't be added. Class " +
qName + " already exists in classpath");
return;
}
@@ -180,12 +179,12 @@ public class AndroidDxRunner {
@Nullable
private static String getQualifiedName(File root, File classFile) {
String relativePath = FileUtil.getRelativePath(root, classFile);
String relativePath = FileUtilRt.getRelativePath(root, classFile);
if (relativePath == null) {
return null;
}
return FileUtil.getNameWithoutExtension(FileUtil.toSystemIndependentName(relativePath)).replace('/', '.');
return FileUtilRt.getNameWithoutExtension(FileUtilRt.toSystemIndependentName(relativePath)).replace('/', '.');
}
public static void main(String[] args) {
@@ -1,8 +0,0 @@
package org.jetbrains.android.util;
/**
* @author Eugene.Kudelevsky
*/
public enum AndroidCompilerMessageKind {
ERROR, INFORMATION, WARNING
}
+1 -1
View File
@@ -217,7 +217,7 @@
<renameHandler implementation="org.jetbrains.android.AndroidRenameHandler" order="first"/>
<compileServer.plugin jar-path="jps/android-jps-plugin.jar"/>
<compileServer.plugin jar-path="android-rt.jar"/>
<compileServer.plugin jar-path="android-common.jar"/>
<compileServer.plugin jar-path="sdklib.jar"/>
<compileServer.plugin jar-path="../../../../../community/plugins/android/lib/sdklib.jar"/>
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2010 JetBrains s.r.o.
* Copyright 2000-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,7 +25,7 @@ import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.openapi.roots.ModuleRootManager;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.io.FileUtilRt;
import com.intellij.util.PathUtil;
import com.intellij.util.PathsList;
import com.intellij.util.containers.HashMap;
@@ -97,7 +97,7 @@ public class AndroidDxWrapper {
}
final PathsList classPath = parameters.getClassPath();
classPath.add(PathUtil.getJarPathForClass(AndroidDxRunner.class));
classPath.add(PathUtil.getJarPathForClass(FileUtil.class));
classPath.add(PathUtil.getJarPathForClass(FileUtilRt.class));
// delete file to check if it will exist after dex compilation
if (!new File(outFile).delete()) {