use of org.jetbrains.jps.android.model.impl.JpsAndroidModuleProperties in project android by JetBrains.
the class ConflictSetTest method createFacet.
@NotNull
private static AndroidFacet createFacet(@NotNull FacetManager facetManager, int projectType) {
AndroidFacet facet = facetManager.createFacet(AndroidFacet.getFacetType(), AndroidFacet.NAME, null);
JpsAndroidModuleProperties facetState = facet.getProperties();
facetState.ALLOW_USER_CONFIGURATION = false;
facetState.PROJECT_TYPE = projectType;
return facet;
}
use of org.jetbrains.jps.android.model.impl.JpsAndroidModuleProperties in project android by JetBrains.
the class AndroidBuilderTest method testProGuardWithJar.
public void testProGuardWithJar() throws Exception {
final MyExecutor executor = new MyExecutor("com.example.simple") {
@Override
protected void doCheckJar(@NotNull String jarId, @NotNull String jarPath) {
if ("proguard_input_jar".equals(jarId)) {
File tmpDir = null;
try {
tmpDir = FileUtil.createTempDirectory("proguard_input_jar_checking", "tmp");
final File jar = new File(tmpDir, "file.jar");
FileUtil.copy(new File(jarPath), jar);
assertOutput(tmpDir.getPath(), TestFileSystemItem.fs().archive("file.jar").dir("com").dir("example").dir("simple").file("BuildConfig.class").file("R.class").file("MyActivity.class"));
} catch (IOException e) {
throw new RuntimeException(e);
} finally {
if (tmpDir != null) {
FileUtil.delete(tmpDir);
}
}
}
}
};
final JpsModule module = setUpSimpleAndroidStructure(new String[] { "src" }, executor, null).getFirst();
module.addSourceRoot(JpsPathUtil.pathToUrl(getProjectPath("tests")), JavaSourceRootType.TEST_SOURCE);
final JpsLibrary lib = module.addModuleLibrary("lib", JpsJavaLibraryType.INSTANCE);
lib.addRoot(new File(getProjectPath("libs/external_jar.jar")), JpsOrderRootType.COMPILED);
module.getDependenciesList().addLibraryDependency(lib);
final JpsAndroidModuleExtension extension = AndroidJpsUtil.getExtension(module);
assert extension instanceof JpsAndroidModuleExtensionImpl;
final JpsAndroidModuleProperties properties = ((JpsAndroidModuleExtensionImpl) extension).getProperties();
assert properties != null;
properties.RUN_PROGUARD = true;
properties.myProGuardCfgFiles = Arrays.asList("file://%MODULE_SDK_HOME%/tools/proguard/proguard-android.txt", VfsUtilCore.pathToUrl(getProjectPath("proguard-project.txt")));
makeAll().assertSuccessful();
checkBuildLog(executor, "expected_log");
checkMakeUpToDate(executor);
doBuild(CompileScopeTestBuilder.rebuild().allModules().targetTypes(AndroidManifestMergingTarget.MyTargetType.INSTANCE, AndroidDexBuildTarget.MyTargetType.INSTANCE, AndroidResourceCachingBuildTarget.MyTargetType.INSTANCE, AndroidResourcePackagingBuildTarget.MyTargetType.INSTANCE, AndroidPackagingBuildTarget.MyTargetType.INSTANCE, AndroidLibraryPackagingTarget.MyTargetType.INSTANCE, AndroidPackagingBuildTarget.MyTargetType.INSTANCE)).assertSuccessful();
checkBuildLog(executor, "expected_log_1");
}
use of org.jetbrains.jps.android.model.impl.JpsAndroidModuleProperties in project android by JetBrains.
the class AndroidBuilderTest method testMaven.
public void testMaven() throws Exception {
createMavenConfigFile();
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("lib2", new String[] { "src" }, "lib", "lib2", androidSdk).getFirst();
final JpsModule libModule1 = addAndroidModule("lib1", new String[] { "src" }, "lib1", "lib1", androidSdk).getFirst();
JpsMavenExtensionService.getInstance().getOrCreateExtension(appModule);
final MavenProjectConfiguration mavenConf = ((JpsMavenExtensionServiceImpl) JpsMavenExtensionService.getInstance()).getMavenProjectConfiguration(myDataStorageRoot);
addMavenResourcesConf(mavenConf, "app");
addMavenResourcesConf(mavenConf, "lib2");
addMavenResourcesConf(mavenConf, "lib1");
final JpsAndroidModuleExtension libExtension = AndroidJpsUtil.getExtension(libModule);
assert libExtension != null;
final JpsAndroidModuleProperties libProps = ((JpsAndroidModuleExtensionImpl) libExtension).getProperties();
libProps.PROJECT_TYPE = PROJECT_TYPE_LIBRARY;
final JpsAndroidModuleExtension libExtension1 = AndroidJpsUtil.getExtension(libModule1);
assert libExtension1 != null;
final JpsAndroidModuleProperties libProps1 = ((JpsAndroidModuleExtensionImpl) libExtension1).getProperties();
libProps1.PROJECT_TYPE = PROJECT_TYPE_LIBRARY;
appModule.getDependenciesList().addModuleDependency(libModule);
libModule.getDependenciesList().addModuleDependency(libModule1);
rebuildAll();
checkBuildLog(executor, "expected_log");
assertOutput(appModule, TestFileSystemItem.fs().file("com").archive("app.apk").dir("lib").file("lib_resource.txt").end().dir("com").file("app_resource.txt").end().file("META-INF").file("res_apk_entry", "res_apk_entry_content").file("classes.dex", "classes_dex_content"));
checkMakeUpToDate(executor);
JpsMavenExtensionService.getInstance().getOrCreateExtension(libModule);
makeAll().assertSuccessful();
checkBuildLog(executor, "expected_log_1");
checkMakeUpToDate(executor);
final JpsModule nonMavenAppModule = addAndroidModule("non_maven_app", new String[] { "src" }, "app", "non_maven_app", androidSdk).getFirst();
nonMavenAppModule.getDependenciesList().addModuleDependency(libModule);
final JpsModule libModule2 = addAndroidModule("lib3", new String[] { "src" }, "lib1", "lib3", androidSdk).getFirst();
final JpsAndroidModuleExtension libExtension2 = AndroidJpsUtil.getExtension(libModule2);
assert libExtension2 != null;
final JpsAndroidModuleProperties libProps2 = ((JpsAndroidModuleExtensionImpl) libExtension2).getProperties();
libProps2.PROJECT_TYPE = PROJECT_TYPE_LIBRARY;
libModule1.getDependenciesList().addModuleDependency(libModule2);
makeAll().assertSuccessful();
checkBuildLog(executor, "expected_log_2");
}
use of org.jetbrains.jps.android.model.impl.JpsAndroidModuleProperties in project android by JetBrains.
the class AndroidBuilderTest method addAndroidModule.
private Pair<JpsModule, Path> addAndroidModule(String moduleName, String[] sourceRoots, String contentRootDir, String dstContentRootDir, JpsSdk<? extends JpsElement> androidSdk, String testDirName) {
final String testDataRoot = getTestDataDirForCurrentTest(testDirName);
final String projectRoot = testDataRoot + "/project";
final String moduleContentRoot = contentRootDir != null ? new File(projectRoot, contentRootDir).getPath() : projectRoot;
final String dstRoot = dstContentRootDir != null ? "root/" + dstContentRootDir : "root";
final String root = copyToProject(moduleContentRoot, dstRoot);
final String outputPath = getAbsolutePath("out/production/" + moduleName);
final String testOutputPath = getAbsolutePath("out/test/" + moduleName);
final JpsModule module = addModule(moduleName, ArrayUtil.EMPTY_STRING_ARRAY, outputPath, testOutputPath, androidSdk);
module.getContentRootsList().addUrl(JpsPathUtil.pathToUrl(root));
for (String sourceRoot : sourceRoots) {
final String sourceRootName = new File(sourceRoot).getName();
final String copiedSourceRoot = copyToProject(moduleContentRoot + "/" + sourceRoot, dstRoot + "/" + sourceRootName);
module.addSourceRoot(JpsPathUtil.pathToUrl(copiedSourceRoot), JavaSourceRootType.SOURCE);
}
final JpsAndroidModuleProperties properties = new JpsAndroidModuleProperties();
properties.MANIFEST_FILE_RELATIVE_PATH = "/AndroidManifest.xml";
properties.RES_FOLDER_RELATIVE_PATH = "/res";
properties.ASSETS_FOLDER_RELATIVE_PATH = "/assets";
properties.LIBS_FOLDER_RELATIVE_PATH = "/libs";
properties.GEN_FOLDER_RELATIVE_PATH_APT = "/gen";
properties.GEN_FOLDER_RELATIVE_PATH_AIDL = "/gen";
properties.PACK_TEST_CODE = false;
module.getContainer().setChild(JpsModuleSerializationDataExtensionImpl.ROLE, new JpsModuleSerializationDataExtensionImpl(Paths.get(root)));
module.getContainer().setChild(JpsAndroidModuleExtensionImpl.KIND, new JpsAndroidModuleExtensionImpl(properties));
return Pair.create(module, Paths.get(root));
}
use of org.jetbrains.jps.android.model.impl.JpsAndroidModuleProperties in project android by JetBrains.
the class AndroidBuilderTest method test9.
public void test9() throws Exception {
final MyExecutor executor = new MyExecutor("com.example.simple");
final JpsSdk<JpsSimpleElement<JpsAndroidSdkProperties>> androidSdk = addJdkAndAndroidSdk();
addPathPatterns(executor, androidSdk);
final JpsModule appModule1 = addAndroidModule("app1", new String[] { "src" }, "app1", "app1", androidSdk).getFirst();
final JpsModule appModule2 = addAndroidModule("app2", new String[] { "src" }, "app2", "app2", 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;
makeAll().assertSuccessful();
checkBuildLog(executor, "expected_log");
assertEquals(1, executor.getCheckedJars().size());
checkMakeUpToDate(executor);
appModule1.getDependenciesList().addModuleDependency(libModule);
makeAll().assertSuccessful();
checkBuildLog(executor, "expected_log_1");
assertTrue(executor.getCheckedJars().isEmpty());
checkMakeUpToDate(executor);
appModule2.getDependenciesList().addModuleDependency(libModule);
makeAll().assertSuccessful();
checkBuildLog(executor, "expected_log_2");
assertTrue(executor.getCheckedJars().isEmpty());
checkMakeUpToDate(executor);
final JpsLibrary appLib = appModule1.addModuleLibrary("appLib1", JpsJavaLibraryType.INSTANCE);
appLib.addRoot(getProjectPath("lib/external_jar.jar"), JpsOrderRootType.COMPILED);
appModule1.getDependenciesList().addLibraryDependency(appLib);
makeAll().assertSuccessful();
checkBuildLog(executor, "expected_log_3");
assertTrue(executor.getCheckedJars().isEmpty());
checkMakeUpToDate(executor);
final JpsLibrary libLib = appModule2.addModuleLibrary("appLib2", JpsJavaLibraryType.INSTANCE);
libLib.addRoot(new File(getProjectPath("lib/external_jar.jar")), JpsOrderRootType.COMPILED);
appModule2.getDependenciesList().addLibraryDependency(libLib);
makeAll().assertSuccessful();
checkBuildLog(executor, "expected_log_4");
assertTrue(executor.getCheckedJars().isEmpty());
checkMakeUpToDate(executor);
}
Aggregations