Search in sources :

Example 56 with JpsModule

use of org.jetbrains.jps.model.module.JpsModule in project android by JetBrains.

the class AndroidBuilderTest method testCustomManifestPackage.

public void testCustomManifestPackage() throws Exception {
    final MyExecutor executor = new MyExecutor("com.example.simple");
    final JpsModule module = setUpSimpleAndroidStructure(new String[] { "src" }, executor, null, "8").getFirst();
    rebuildAll();
    checkMakeUpToDate(executor);
    final JpsAndroidModuleExtensionImpl extension = (JpsAndroidModuleExtensionImpl) AndroidJpsUtil.getExtension(module);
    assert extension != null;
    final JpsAndroidModuleProperties props = extension.getProperties();
    props.CUSTOM_MANIFEST_PACKAGE = "dev";
    checkMakeUpToDate(executor);
    props.USE_CUSTOM_MANIFEST_PACKAGE = true;
    makeAll().assertSuccessful();
    checkBuildLog(executor, "expected_log");
    checkMakeUpToDate(executor);
    props.CUSTOM_MANIFEST_PACKAGE = "dev1";
    makeAll().assertSuccessful();
    checkBuildLog(executor, "expected_log_1");
    checkMakeUpToDate(executor);
}
Also used : JpsModule(org.jetbrains.jps.model.module.JpsModule) JpsAndroidModuleExtensionImpl(org.jetbrains.jps.android.model.impl.JpsAndroidModuleExtensionImpl) JpsAndroidModuleProperties(org.jetbrains.jps.android.model.impl.JpsAndroidModuleProperties)

Example 57 with JpsModule

use of org.jetbrains.jps.model.module.JpsModule in project android by JetBrains.

the class AndroidBuilderTest method testGeneratedSources.

public void testGeneratedSources() throws Exception {
    final MyExecutor executor = new MyExecutor("com.example.simple");
    final JpsModule module = setUpSimpleAndroidStructure(new String[] { "src", "gen" }, executor, null).getFirst();
    rebuildAll();
    checkBuildLog(executor, "expected_log");
    checkMakeUpToDate(executor);
    change(getProjectPath("gen/com/example/simple/R.java"), AndroidCommonUtils.AUTOGENERATED_JAVA_FILE_HEADER + "\n\n" + "package com.example.simple;\n" + "public class R {}");
    makeAll().assertSuccessful();
    checkBuildLog(executor, "expected_log_1");
    assertCompiled(JavaBuilder.BUILDER_NAME, "targets/java-production/module/android/copied_sources/com/example/simple/MyGeneratedClass.java");
    checkMakeUpToDate(executor);
    change(getProjectPath("gen/com/example/simple/R.java"));
    checkMakeUpToDate(executor);
    change(getProjectPath("gen/com/example/simple/MyGeneratedClass.java"));
    makeAll().assertSuccessful();
    checkBuildLog(executor, "expected_log_3");
    assertCompiled(JavaBuilder.BUILDER_NAME, "targets/java-production/module/android/copied_sources/com/example/simple/MyGeneratedClass.java");
    checkMakeUpToDate(executor);
    change(getProjectPath("gen/com/example/simple/MyGeneratedClass.java"), AndroidCommonUtils.AUTOGENERATED_JAVA_FILE_HEADER + "\n\n" + "package com.example.simple;\n" + "public class MyGeneratedClass {}");
    makeAll().assertSuccessful();
    checkBuildLog(executor, "expected_log_4");
    assertCompiled(JavaBuilder.BUILDER_NAME);
    checkMakeUpToDate(executor);
    change(getProjectPath("gen/com/example/simple/MyGeneratedClass.java"), "package com.example.simple;\n" + "public class MyGeneratedClass {}");
    change(getProjectPath("src/com/example/simple/MyActivity.java"), "package com.example.simple;\n" + "import android.app.Activity;\n" + "import android.os.Bundle;\n" + "public class MyActivity extends Activity {\n" + "    public void onCreate(Bundle savedInstanceState) {\n" + "        super.onCreate(savedInstanceState);\n" + "        new MyGeneratedClass();" + "    }\n" + "}\n");
    makeAll().assertSuccessful();
    checkBuildLog(executor, "expected_log_5");
    assertCompiled(JavaBuilder.BUILDER_NAME, "root/src/com/example/simple/MyActivity.java", "targets/java-production/module/android/copied_sources/com/example/simple/MyGeneratedClass.java");
    checkMakeUpToDate(executor);
    final JpsJavaCompilerConfiguration compilerConfig = JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(myProject);
    final ProcessorConfigProfile profile = compilerConfig.getAnnotationProcessingProfile(module);
    profile.setEnabled(true);
    profile.setOutputRelativeToContentRoot(true);
    profile.setGeneratedSourcesDirectoryName("gen", false);
    final BuildResult result = makeAll();
    result.assertFailed();
    final List<BuildMessage> warnMessages = result.getMessages(BuildMessage.Kind.WARNING);
    boolean containsForciblyExcludedRootWarn = false;
    for (BuildMessage message : warnMessages) {
        if (message.getMessageText().endsWith("was forcibly excluded by the IDE, so custom generated files won't be compiled")) {
            containsForciblyExcludedRootWarn = true;
        }
    }
    assertTrue(containsForciblyExcludedRootWarn);
}
Also used : BuildMessage(org.jetbrains.jps.incremental.messages.BuildMessage) JpsModule(org.jetbrains.jps.model.module.JpsModule) JpsJavaCompilerConfiguration(org.jetbrains.jps.model.java.compiler.JpsJavaCompilerConfiguration) BuildResult(org.jetbrains.jps.builders.BuildResult) ProcessorConfigProfile(org.jetbrains.jps.model.java.compiler.ProcessorConfigProfile)

Example 58 with JpsModule

use of org.jetbrains.jps.model.module.JpsModule in project android by JetBrains.

the class AndroidBuilderTest method test5.

public void test5() throws Exception {
    final MyExecutor executor = new MyExecutor("com.example.simple");
    final JpsSdk<JpsSimpleElement<JpsAndroidSdkProperties>> androidSdk = addJdkAndAndroidSdk();
    addPathPatterns(executor, androidSdk);
    final JpsModule appModule = addAndroidModule("app", new String[] { "src" }, "app", "app", androidSdk).getFirst();
    final JpsModule libModule = addAndroidModule("lib", ArrayUtil.EMPTY_STRING_ARRAY, "lib", "lib", androidSdk).getFirst();
    final JpsAndroidModuleExtension libExtension = AndroidJpsUtil.getExtension(libModule);
    assert libExtension != null;
    final JpsAndroidModuleProperties libProps = ((JpsAndroidModuleExtensionImpl) libExtension).getProperties();
    libProps.PROJECT_TYPE = PROJECT_TYPE_LIBRARY;
    rebuildAll();
    checkBuildLog(executor, "expected_log");
    checkMakeUpToDate(executor);
    appModule.getDependenciesList().addModuleDependency(libModule);
    makeAll().assertSuccessful();
    checkBuildLog(executor, "expected_log_1");
    checkMakeUpToDate(executor);
    final JpsAndroidModuleExtension appExtension = AndroidJpsUtil.getExtension(appModule);
    assert appExtension != null;
    final JpsAndroidModuleProperties appProps = ((JpsAndroidModuleExtensionImpl) appExtension).getProperties();
    appProps.myIncludeAssetsFromLibraries = true;
    makeAll();
    checkBuildLog(executor, "expected_log_2");
    checkMakeUpToDate(executor);
    rebuildAll();
    checkBuildLog(executor, "expected_log_7");
    checkMakeUpToDate(executor);
    change(getProjectPath("lib/assets/lib_asset.txt"));
    makeAll();
    checkBuildLog(executor, "expected_log_3");
    checkMakeUpToDate(executor);
    change(getProjectPath("app/assets/app_asset.txt"));
    makeAll();
    checkBuildLog(executor, "expected_log_3");
    checkMakeUpToDate(executor);
    change(getProjectPath("lib/res/values/strings.xml"));
    makeAll();
    checkBuildLog(executor, "expected_log_4");
    checkMakeUpToDate(executor);
    change(getProjectPath("app/res/values/strings.xml"));
    makeAll();
    checkBuildLog(executor, "expected_log_5");
    checkMakeUpToDate(executor);
    assertTrue(FileUtil.delete(new File(getProjectPath("lib/assets"))));
    makeAll();
    checkBuildLog(executor, "expected_log_6");
    checkMakeUpToDate(executor);
}
Also used : JpsModule(org.jetbrains.jps.model.module.JpsModule) JpsAndroidModuleExtensionImpl(org.jetbrains.jps.android.model.impl.JpsAndroidModuleExtensionImpl) JpsSimpleElement(org.jetbrains.jps.model.JpsSimpleElement) JpsAndroidModuleProperties(org.jetbrains.jps.android.model.impl.JpsAndroidModuleProperties)

Example 59 with JpsModule

use of org.jetbrains.jps.model.module.JpsModule in project android by JetBrains.

the class AndroidBuilderTest method testResOverlay.

public void testResOverlay() throws Exception {
    final MyExecutor executor = new MyExecutor("com.example.simple");
    final JpsModule module = setUpSimpleAndroidStructure(ArrayUtil.EMPTY_STRING_ARRAY, executor, null).getFirst();
    final JpsAndroidModuleProperties props = ((JpsAndroidModuleExtensionImpl) AndroidJpsUtil.getExtension(module)).getProperties();
    props.RES_OVERLAY_FOLDERS = Arrays.asList("/res-overlay");
    rebuildAll();
    checkBuildLog(executor, "expected_log");
    checkMakeUpToDate(executor);
    props.RES_OVERLAY_FOLDERS = Collections.emptyList();
    makeAll().assertSuccessful();
    checkBuildLog(executor, "expected_log_1");
}
Also used : JpsModule(org.jetbrains.jps.model.module.JpsModule) JpsAndroidModuleExtensionImpl(org.jetbrains.jps.android.model.impl.JpsAndroidModuleExtensionImpl) JpsAndroidModuleProperties(org.jetbrains.jps.android.model.impl.JpsAndroidModuleProperties)

Example 60 with JpsModule

use of org.jetbrains.jps.model.module.JpsModule in project android by JetBrains.

the class AndroidBuilderTest method test3.

public void test3() throws Exception {
    final MyExecutor executor = new MyExecutor("com.example.simple");
    final JpsModule module = setUpSimpleAndroidStructure(new String[] { "src", "resources" }, executor, null).getFirst();
    module.addSourceRoot(JpsPathUtil.pathToUrl(getProjectPath("tests")), JavaSourceRootType.TEST_SOURCE);
    final JpsLibrary lib1 = module.addModuleLibrary("lib1", JpsJavaLibraryType.INSTANCE);
    lib1.addRoot(getProjectPath("external_jar1.jar"), JpsOrderRootType.COMPILED);
    final JpsLibrary lib2 = module.addModuleLibrary("lib2", JpsJavaLibraryType.INSTANCE);
    lib2.addRoot(new File(getProjectPath("libs/external_jar2.jar")), JpsOrderRootType.COMPILED);
    module.getDependenciesList().addLibraryDependency(lib1);
    rebuildAll();
    checkBuildLog(executor, "expected_log");
    assertOutput(module, TestFileSystemItem.fs().file("java_resource1.txt").dir("com").dir("example").file("java_resource3.txt").dir("simple").file("BuildConfig.class").file("R.class").file("MyActivity.class").end().end().end().archive("module.apk").file("resource_inside_jar1.txt").file("java_resource1.txt").dir("com").dir("example").file("java_resource3.txt").end().end().file("META-INF").file("res_apk_entry", "res_apk_entry_content").file("classes.dex", "classes_dex_content"));
    checkMakeUpToDate(executor);
    module.getDependenciesList().addLibraryDependency(lib2);
    executor.clear();
    makeAll().assertSuccessful();
    checkBuildLog(executor, "expected_log_1");
    assertOutput(module, TestFileSystemItem.fs().file("java_resource1.txt").file("com").archive("module.apk").file("resource_inside_jar2.txt").file("java_resource1.txt").file("com").file("META-INF").file("res_apk_entry", "res_apk_entry_content").file("classes.dex", "classes_dex_content"));
    checkMakeUpToDate(executor);
    change(getProjectPath("resources/com/example/java_resource3.txt"));
    executor.clear();
    makeAll().assertSuccessful();
    checkBuildLog(executor, "expected_log_2");
    assertOutput(module, TestFileSystemItem.fs().file("java_resource1.txt").file("com").archive("module.apk").file("resource_inside_jar2.txt").file("java_resource1.txt").file("com").file("META-INF").file("res_apk_entry", "res_apk_entry_content").file("classes.dex", "classes_dex_content"));
    checkMakeUpToDate(executor);
    assertTrue(FileUtil.delete(new File(getProjectPath("external_jar1.jar"))));
    makeAll().assertSuccessful();
    checkBuildLog(executor, "expected_log_3");
    assertOutput(module, TestFileSystemItem.fs().file("java_resource1.txt").file("com").archive("module.apk").file("resource_inside_jar1.txt").file("resource_inside_jar2.txt").file("java_resource1.txt").file("com").file("META-INF").file("res_apk_entry", "res_apk_entry_content").file("classes.dex", "classes_dex_content"));
    checkMakeUpToDate(executor);
    assertTrue(FileUtil.delete(new File(getProjectPath("src/java_resource1.txt"))));
    makeAll().assertSuccessful();
    checkBuildLog(executor, "expected_log_4");
    assertOutput(module, TestFileSystemItem.fs().file("com").archive("module.apk").file("resource_inside_jar1.txt").file("resource_inside_jar2.txt").file("com").file("META-INF").file("res_apk_entry", "res_apk_entry_content").file("classes.dex", "classes_dex_content"));
    checkMakeUpToDate(executor);
    module.removeSourceRoot(JpsPathUtil.pathToUrl(getProjectPath("resources")), JavaSourceRootType.SOURCE);
    makeAll().assertSuccessful();
    checkBuildLog(executor, "expected_log_5");
    checkMakeUpToDate(executor);
}
Also used : JpsModule(org.jetbrains.jps.model.module.JpsModule) JpsLibrary(org.jetbrains.jps.model.library.JpsLibrary)

Aggregations

JpsModule (org.jetbrains.jps.model.module.JpsModule)128 File (java.io.File)33 NotNull (org.jetbrains.annotations.NotNull)15 CompilerMessage (org.jetbrains.jps.incremental.messages.CompilerMessage)15 JpsAndroidModuleExtension (org.jetbrains.jps.android.model.JpsAndroidModuleExtension)14 JpsAndroidModuleExtensionImpl (org.jetbrains.jps.android.model.impl.JpsAndroidModuleExtensionImpl)13 JpsAndroidModuleProperties (org.jetbrains.jps.android.model.impl.JpsAndroidModuleProperties)13 THashSet (gnu.trove.THashSet)11 JpsLibrary (org.jetbrains.jps.model.library.JpsLibrary)11 ProgressMessage (org.jetbrains.jps.incremental.messages.ProgressMessage)10 JpsSimpleElement (org.jetbrains.jps.model.JpsSimpleElement)10 JpsArtifact (org.jetbrains.jps.model.artifact.JpsArtifact)10 ArrayList (java.util.ArrayList)9 HashMap (com.intellij.util.containers.HashMap)8 IOException (java.io.IOException)8 TObjectLongHashMap (gnu.trove.TObjectLongHashMap)7 JpsDependencyElement (org.jetbrains.jps.model.module.JpsDependencyElement)7 JpsDummyElement (org.jetbrains.jps.model.JpsDummyElement)6 Pair (com.intellij.openapi.util.Pair)5 Nullable (org.jetbrains.annotations.Nullable)5