diff options
-rw-r--r-- | anttasks/src/com/android/ant/SetupTask.java | 15 | ||||
-rw-r--r-- | eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/PreCompilerBuilder.java | 19 |
2 files changed, 30 insertions, 4 deletions
diff --git a/anttasks/src/com/android/ant/SetupTask.java b/anttasks/src/com/android/ant/SetupTask.java index f13cccd..72f5d11 100644 --- a/anttasks/src/com/android/ant/SetupTask.java +++ b/anttasks/src/com/android/ant/SetupTask.java @@ -264,8 +264,23 @@ public final class SetupTask extends ImportTask { XPath xPath = AndroidXPathFactory.newXPath(); + // check the package name. String value = xPath.evaluate( "/" + AndroidManifest.NODE_MANIFEST + + "/@" + AndroidManifest.ATTRIBUTE_PACKAGE, + new InputSource(new FileInputStream(manifest))); + if (value != null) { // aapt will complain if it's missing. + // only need to check that the package has 2 segments + if (value.indexOf('.') == -1) { + throw new BuildException(String.format( + "Application package '%1$s' must have a minimum of 2 segments.", + value)); + } + } + + // check the minSdkVersion value + value = xPath.evaluate( + "/" + AndroidManifest.NODE_MANIFEST + "/" + AndroidManifest.NODE_USES_SDK + "/@" + AndroidXPathFactory.DEFAULT_NS_PREFIX + ":" + AndroidManifest.ATTRIBUTE_MIN_SDK_VERSION, 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/PreCompilerBuilder.java index da73406..ee85e1b 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/PreCompilerBuilder.java @@ -406,18 +406,29 @@ public class PreCompilerBuilder extends BaseBuilder { String msg = String.format(Messages.s_Doesnt_Declare_Package_Error, AndroidConstants.FN_ANDROID_MANIFEST); AdtPlugin.printErrorToConsole(project, msg); - markProject(AndroidConstants.MARKER_ADT, msg, IMarker.SEVERITY_ERROR); + BaseProjectHelper.markResource(manifest, AndroidConstants.MARKER_ADT, + msg, IMarker.SEVERITY_ERROR); // This interrupts the build. The next builders will not run. + // This also throws an exception and nothing beyond this line will run. stopBuild(msg); + } else if (javaPackage.indexOf('.') == -1) { + // The application package name does not contain 2+ segments! + String msg = String.format( + "Application package '%1$s' must have a minimum of 2 segments.", + AndroidConstants.FN_ANDROID_MANIFEST); + AdtPlugin.printErrorToConsole(project, msg); + BaseProjectHelper.markResource(manifest, AndroidConstants.MARKER_ADT, + msg, IMarker.SEVERITY_ERROR); - // TODO: document whether code below that uses javaPackage (which is now guaranteed - // to be null) will actually be executed or not. + // This interrupts the build. The next builders will not run. + // This also throws an exception and nothing beyond this line will run. + stopBuild(msg); } // at this point we have the java package. We need to make sure it's not a different // package than the previous one that were built. - if (javaPackage != null && javaPackage.equals(mManifestPackage) == false) { + if (javaPackage.equals(mManifestPackage) == false) { // The manifest package has changed, the user may want to update // the launch configuration if (mManifestPackage != null) { |