use of org.jetbrains.jps.model.library.JpsLibrary in project intellij-community by JetBrains.
the class JpsGlobalSerializationTest method testLoadSdksAndGlobalLibraries.
public void testLoadSdksAndGlobalLibraries() {
loadGlobalSettings(OPTIONS_DIR);
final List<JpsLibrary> libraries = myModel.getGlobal().getLibraryCollection().getLibraries();
assertEquals(3, libraries.size());
assertEquals("Gant", libraries.get(0).getName());
final JpsLibrary sdk1 = libraries.get(1);
assertEquals("1.5", sdk1.getName());
final JpsLibrary sdk2 = libraries.get(2);
assertEquals("1.6", sdk2.getName());
}
use of org.jetbrains.jps.model.library.JpsLibrary in project intellij-community by JetBrains.
the class JpsLibraryFilesPackagingElementImpl method getSubstitution.
@Override
public List<JpsPackagingElement> getSubstitution() {
JpsLibrary library = getLibraryReference().resolve();
if (library == null)
return Collections.emptyList();
List<JpsPackagingElement> result = new ArrayList<>();
for (File file : library.getFiles(JpsOrderRootType.COMPILED)) {
String path = FileUtil.toSystemIndependentName(file.getAbsolutePath());
if (file.isDirectory()) {
result.add(JpsPackagingElementFactory.getInstance().createDirectoryCopy(path));
} else {
result.add(JpsPackagingElementFactory.getInstance().createFileCopy(path, null));
}
}
return result;
}
use of org.jetbrains.jps.model.library.JpsLibrary in project intellij-community by JetBrains.
the class JpsModuleTest method testAddDependency.
public void testAddDependency() {
final JpsModule module = myProject.addModule("m", JpsJavaModuleType.INSTANCE);
final JpsLibrary library = myProject.addLibrary("l", JpsJavaLibraryType.INSTANCE);
final JpsModule dep = myProject.addModule("dep", JpsJavaModuleType.INSTANCE);
module.getDependenciesList().addLibraryDependency(library);
module.getDependenciesList().addModuleDependency(dep);
final List<? extends JpsDependencyElement> dependencies = module.getDependenciesList().getDependencies();
assertEquals(3, dependencies.size());
assertInstanceOf(dependencies.get(0), JpsModuleSourceDependency.class);
assertSame(library, assertInstanceOf(dependencies.get(1), JpsLibraryDependency.class).getLibrary());
assertSame(dep, assertInstanceOf(dependencies.get(2), JpsModuleDependency.class).getModule());
}
use of org.jetbrains.jps.model.library.JpsLibrary in project kotlin by JetBrains.
the class JpsUtils method isJsKotlinModuleImpl.
private static boolean isJsKotlinModuleImpl(@NotNull ModuleBuildTarget target) {
TargetPlatformKind<?> targetPlatform = JpsKotlinCompilerSettingsKt.getTargetPlatform(target.getModule());
if (targetPlatform != null)
return targetPlatform == TargetPlatformKind.JavaScript.INSTANCE;
Set<JpsLibrary> libraries = getAllDependencies(target).getLibraries();
for (JpsLibrary library : libraries) {
for (JpsLibraryRoot root : library.getRoots(JpsOrderRootType.COMPILED)) {
String url = root.getUrl();
Boolean cachedValue = IS_KOTLIN_JS_STDLIB_JAR_CACHE.get(url);
if (cachedValue != null) {
if (cachedValue.booleanValue())
return true;
else
continue;
}
boolean isKotlinJavascriptStdLibrary = LibraryUtils.isKotlinJavascriptStdLibrary(JpsPathUtil.urlToFile(url));
IS_KOTLIN_JS_STDLIB_JAR_CACHE.put(url, isKotlinJavascriptStdLibrary);
if (isKotlinJavascriptStdLibrary)
return true;
}
}
return false;
}
use of org.jetbrains.jps.model.library.JpsLibrary 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);
}
Aggregations