Search in sources :

Example 1 with JpsAndroidModuleExtensionImpl

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

the class AndroidBuilderTest method testManifestMerging.

public void testManifestMerging() 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;
    appModule.getDependenciesList().addModuleDependency(libModule);
    final JpsAndroidModuleExtension appExtension = AndroidJpsUtil.getExtension(appModule);
    assert appExtension != null;
    final JpsAndroidModuleProperties appProps = ((JpsAndroidModuleExtensionImpl) appExtension).getProperties();
    appProps.ENABLE_MANIFEST_MERGING = true;
    makeAll().assertSuccessful();
    checkBuildLog(executor, "expected_log");
    checkMakeUpToDate(executor);
    appProps.ENABLE_MANIFEST_MERGING = false;
    makeAll().assertSuccessful();
    checkBuildLog(executor, "expected_log_1");
    checkMakeUpToDate(executor);
    appProps.ENABLE_MANIFEST_MERGING = true;
    makeAll().assertSuccessful();
    checkBuildLog(executor, "expected_log_2");
    checkMakeUpToDate(executor);
    change(getProjectPath("app/AndroidManifest.xml"));
    makeAll().assertSuccessful();
    checkBuildLog(executor, "expected_log_3");
    checkMakeUpToDate(executor);
    change(getProjectPath("lib/AndroidManifest.xml"));
    makeAll().assertSuccessful();
    checkBuildLog(executor, "expected_log_4");
    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 2 with JpsAndroidModuleExtensionImpl

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

the class AndroidBuilderTest method testMaven1.

public void testMaven1() throws Exception {
    createMavenConfigFile();
    final MyExecutor executor = new MyExecutor("com.example.simple");
    final JpsSdk<JpsSimpleElement<JpsAndroidSdkProperties>> androidSdk = addJdkAndAndroidSdk();
    addPathPatterns(executor, androidSdk);
    copyToProject(getDefaultTestDataDirForCurrentTest() + "/project/myaar", "root/myaar");
    final JpsModule appModule = addAndroidModule("app", new String[] { "src" }, "app", "app", androidSdk).getFirst();
    final JpsModule libModule = addAndroidModule("lib", new String[] { "src" }, "lib", "lib", androidSdk).getFirst();
    JpsMavenExtensionService.getInstance().getOrCreateExtension(appModule);
    final MavenProjectConfiguration mavenConf = ((JpsMavenExtensionServiceImpl) JpsMavenExtensionService.getInstance()).getMavenProjectConfiguration(myDataStorageRoot);
    addMavenResourcesConf(mavenConf, "app");
    addMavenResourcesConf(mavenConf, "lib");
    final JpsAndroidModuleExtension libExtension = AndroidJpsUtil.getExtension(libModule);
    assert libExtension != null;
    final JpsAndroidModuleProperties libProps = ((JpsAndroidModuleExtensionImpl) libExtension).getProperties();
    libProps.PROJECT_TYPE = PROJECT_TYPE_LIBRARY;
    appModule.getDependenciesList().addModuleDependency(libModule);
    rebuildAll();
    checkMakeUpToDate(executor);
    final JpsLibrary appAarLib = appModule.addModuleLibrary("app_arr", JpsJavaLibraryType.INSTANCE);
    appAarLib.addRoot(getProjectPath("myaar/classes.jar"), JpsOrderRootType.COMPILED);
    appModule.getDependenciesList().addLibraryDependency(appAarLib);
    makeAll().assertSuccessful();
    checkBuildLog(executor, "expected_log");
    checkMakeUpToDate(executor);
    appAarLib.addRoot(getProjectPath("myaar/res"), JpsOrderRootType.COMPILED);
    makeAll().assertSuccessful();
    checkBuildLog(executor, "expected_log_1");
    checkMakeUpToDate(executor);
    final JpsLibrary libAarLib = libModule.addModuleLibrary("lib_arr", JpsJavaLibraryType.INSTANCE);
    libAarLib.addRoot(getProjectPath("myaar/classes.jar"), JpsOrderRootType.COMPILED);
    libAarLib.addRoot(getProjectPath("myaar/res"), JpsOrderRootType.COMPILED);
    libModule.getDependenciesList().addLibraryDependency(libAarLib);
    makeAll().assertSuccessful();
    checkBuildLog(executor, "expected_log_2");
    checkMakeUpToDate(executor);
    final JpsAndroidModuleExtension appExtension = AndroidJpsUtil.getExtension(appModule);
    final JpsAndroidModuleProperties appProps = ((JpsAndroidModuleExtensionImpl) appExtension).getProperties();
    appProps.myIncludeAssetsFromLibraries = true;
    makeAll().assertSuccessful();
    checkBuildLog(executor, "expected_log_3");
    checkMakeUpToDate(executor);
    appAarLib.addRoot(getProjectPath("myaar/libs/myjar.jar"), JpsOrderRootType.COMPILED);
    makeAll().assertSuccessful();
    checkBuildLog(executor, "expected_log_4");
    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) JpsLibrary(org.jetbrains.jps.model.library.JpsLibrary)

Example 3 with JpsAndroidModuleExtensionImpl

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

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

use of org.jetbrains.jps.android.model.impl.JpsAndroidModuleExtensionImpl 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)

Aggregations

JpsAndroidModuleExtensionImpl (org.jetbrains.jps.android.model.impl.JpsAndroidModuleExtensionImpl)13 JpsAndroidModuleProperties (org.jetbrains.jps.android.model.impl.JpsAndroidModuleProperties)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)2 TestFileSystemBuilder (com.intellij.util.io.TestFileSystemBuilder)1 JpsModuleSerializationDataExtensionImpl (org.jetbrains.jps.model.serialization.impl.JpsModuleSerializationDataExtensionImpl)1