Search in sources :

Example 11 with JpsAndroidModuleProperties

use of org.jetbrains.jps.android.model.impl.JpsAndroidModuleProperties in project android by JetBrains.

the class AndroidBuilderTest method testAdditionalParameters.

public void testAdditionalParameters() 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.ADDITIONAL_PACKAGING_COMMAND_LINE_PARAMETERS = "-0 xml";
    makeAll().assertSuccessful();
    checkBuildLog(executor, "expected_log");
    checkMakeUpToDate(executor);
    props.ADDITIONAL_PACKAGING_COMMAND_LINE_PARAMETERS = "-0 txt";
    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 12 with JpsAndroidModuleProperties

use of org.jetbrains.jps.android.model.impl.JpsAndroidModuleProperties 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 13 with JpsAndroidModuleProperties

use of org.jetbrains.jps.android.model.impl.JpsAndroidModuleProperties 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 14 with JpsAndroidModuleProperties

use of org.jetbrains.jps.android.model.impl.JpsAndroidModuleProperties 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 15 with JpsAndroidModuleProperties

use of org.jetbrains.jps.android.model.impl.JpsAndroidModuleProperties in project android by JetBrains.

the class AndroidBuilderTest method test7.

public void test7() throws Exception {
    final boolean[] class1Deleted = { false };
    final MyExecutor executor = new MyExecutor("com.example.simple") {

        @Override
        protected void doCheckJar(@NotNull String jarId, @NotNull String jarPath) {
            if ("library_package_jar".equals(jarId)) {
                File tmpDir = null;
                try {
                    tmpDir = FileUtil.createTempDirectory("library_package_jar_checking", "tmp");
                    final File jar = new File(tmpDir, "file.jar");
                    FileUtil.copy(new File(jarPath), jar);
                    TestFileSystemBuilder fs = TestFileSystemItem.fs().archive("file.jar").dir("lib").file("MyLibClass.class");
                    if (!class1Deleted[0]) {
                        fs = fs.file("MyLibClass1.class");
                    }
                    assertOutput(tmpDir.getPath(), fs);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                } finally {
                    if (tmpDir != null) {
                        FileUtil.delete(tmpDir);
                    }
                }
            }
        }
    };
    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", new String[] { "src" }, "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");
    assertEquals(Collections.singleton("library_package_jar"), executor.getCheckedJars());
    checkMakeUpToDate(executor);
    appModule.getDependenciesList().addModuleDependency(libModule);
    makeAll();
    checkBuildLog(executor, "expected_log_1");
    assertTrue(executor.getCheckedJars().isEmpty());
    checkMakeUpToDate(executor);
    change(getProjectPath("lib/src/lib/MyLibClass.java"));
    makeAll();
    checkBuildLog(executor, "expected_log_2");
    assertEquals(Collections.singleton("library_package_jar"), executor.getCheckedJars());
    checkMakeUpToDate(executor);
    assertTrue(FileUtil.delete(new File(getProjectPath("lib/src/lib/MyLibClass1.java"))));
    class1Deleted[0] = true;
    makeAll();
    checkBuildLog(executor, "expected_log_2");
    assertEquals(Collections.singleton("library_package_jar"), executor.getCheckedJars());
    checkMakeUpToDate(executor);
    assertTrue(FileUtil.delete(new File(getProjectPath("lib/src/lib/MyLibClass.java"))));
    makeAll();
    checkBuildLog(executor, "expected_log_3");
    assertTrue(executor.getCheckedJars().isEmpty());
    checkMakeUpToDate(executor);
    final JpsLibrary appLib = appModule.addModuleLibrary("appLib", JpsJavaLibraryType.INSTANCE);
    appLib.addRoot(getProjectPath("lib/external_jar.jar"), JpsOrderRootType.COMPILED);
    appModule.getDependenciesList().addLibraryDependency(appLib);
    final JpsLibrary libLib = libModule.addModuleLibrary("libLib", JpsJavaLibraryType.INSTANCE);
    libLib.addRoot(new File(getProjectPath("lib/external_jar.jar")), JpsOrderRootType.COMPILED);
    libModule.getDependenciesList().addLibraryDependency(libLib);
    makeAll().assertSuccessful();
    checkBuildLog(executor, "expected_log_4");
    assertTrue(executor.getCheckedJars().isEmpty());
    checkMakeUpToDate(executor);
}
Also used : TestFileSystemBuilder(com.intellij.util.io.TestFileSystemBuilder) JpsSimpleElement(org.jetbrains.jps.model.JpsSimpleElement) JpsAndroidModuleProperties(org.jetbrains.jps.android.model.impl.JpsAndroidModuleProperties) NotNull(org.jetbrains.annotations.NotNull) JpsModule(org.jetbrains.jps.model.module.JpsModule) JpsAndroidModuleExtensionImpl(org.jetbrains.jps.android.model.impl.JpsAndroidModuleExtensionImpl) JpsLibrary(org.jetbrains.jps.model.library.JpsLibrary)

Aggregations

JpsAndroidModuleProperties (org.jetbrains.jps.android.model.impl.JpsAndroidModuleProperties)23 JpsAndroidModuleExtensionImpl (org.jetbrains.jps.android.model.impl.JpsAndroidModuleExtensionImpl)13 JpsModule (org.jetbrains.jps.model.module.JpsModule)13 JpsSimpleElement (org.jetbrains.jps.model.JpsSimpleElement)7 JpsLibrary (org.jetbrains.jps.model.library.JpsLibrary)5 NotNull (org.jetbrains.annotations.NotNull)4 AndroidFacet (org.jetbrains.android.facet.AndroidFacet)3 AndroidModuleModel (com.android.tools.idea.gradle.project.model.AndroidModuleModel)2 Module (com.intellij.openapi.module.Module)2 File (java.io.File)2 BaseArtifact (com.android.builder.model.BaseArtifact)1 SourceProvider (com.android.builder.model.SourceProvider)1 GradleBuildFile (com.android.tools.idea.gradle.parser.GradleBuildFile)1 GradleSettingsFile (com.android.tools.idea.gradle.parser.GradleSettingsFile)1 GradleFacet (com.android.tools.idea.gradle.project.facet.gradle.GradleFacet)1 JavaFacet (com.android.tools.idea.gradle.project.facet.java.JavaFacet)1 NdkFacet (com.android.tools.idea.gradle.project.facet.ndk.NdkFacet)1 NdkModuleModel (com.android.tools.idea.gradle.project.model.NdkModuleModel)1 GradleSyncState (com.android.tools.idea.gradle.project.sync.GradleSyncState)1 AndroidModel (com.android.tools.idea.model.AndroidModel)1