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);
}
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);
}
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);
}
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");
}
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);
}
Aggregations