use of org.jetbrains.jps.model.library.JpsLibrary 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);
}
use of org.jetbrains.jps.model.library.JpsLibrary 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);
}
use of org.jetbrains.jps.model.library.JpsLibrary in project intellij-elixir by KronicDeth.
the class Builder method erlangSdkNameToErlExePath.
@NotNull
private static String erlangSdkNameToErlExePath(@NotNull String erlangSdkName, @NotNull JpsModule module) throws LibraryNotFound, FileNotFoundException, AccessDeniedException {
JpsLibraryCollection libraryCollection = module.getProject().getModel().getGlobal().getLibraryCollection();
JpsLibrary erlangSdkLibrary = libraryCollection.findLibrary(erlangSdkName);
String erlExePath;
if (erlangSdkLibrary != null) {
erlExePath = erlangSdkLibraryToErlExePath(erlangSdkLibrary);
} else {
throw new LibraryNotFound(erlangSdkName);
}
return erlExePath;
}
use of org.jetbrains.jps.model.library.JpsLibrary in project android by JetBrains.
the class AndroidAarDepsBuildTarget method doComputeRootDescriptors.
@NotNull
@Override
protected List<BuildRootDescriptor> doComputeRootDescriptors(JpsModel model, ModuleExcludeIndex index, IgnoredFileIndex ignoredFileIndex, BuildDataPaths dataPaths) {
final Set<JpsLibrary> libraries = JpsJavaExtensionService.getInstance().enumerateDependencies(Collections.singleton(myModule)).runtimeOnly().productionOnly().getLibraries();
final List<BuildRootDescriptor> result = new ArrayList<BuildRootDescriptor>();
for (JpsLibrary library : libraries) {
final Pair<File, List<File>> pair = AndroidJpsUtil.getResDirAndJarsIfAar(library);
final List<File> jars = pair != null ? pair.getSecond() : null;
if (jars != null) {
for (File jar : jars) {
result.add(new BuildRootDescriptorImpl(this, jar));
}
}
}
return result;
}
use of org.jetbrains.jps.model.library.JpsLibrary in project android by JetBrains.
the class AndroidDexBuilder method getJavaExecutable.
@Nullable
private static String getJavaExecutable(@NotNull AndroidPlatform platform, @NotNull CompileContext context, @NotNull String builderName) {
final JpsSdk<JpsSimpleElement<JpsAndroidSdkProperties>> sdk = platform.getSdk();
final String jdkName = sdk.getSdkProperties().getData().getJdkName();
final JpsLibrary javaSdk = context.getProjectDescriptor().getModel().getGlobal().getLibraryCollection().findLibrary(jdkName);
if (javaSdk == null || !javaSdk.getType().equals(JpsJavaSdkType.INSTANCE)) {
context.processMessage(new CompilerMessage(builderName, BuildMessage.Kind.ERROR, AndroidJpsBundle.message("android.jps.errors.java.sdk.not.specified", jdkName)));
return null;
}
return JpsJavaSdkType.getJavaExecutable((JpsSdk<?>) javaSdk.getProperties());
}
Aggregations