use of org.jetbrains.jps.model.JpsSimpleElement in project intellij-community by JetBrains.
the class DependencyResolvingBuilder method getRepositoryLibraries.
@NotNull
private static Collection<JpsTypedLibrary<JpsSimpleElement<RepositoryLibraryDescriptor>>> getRepositoryLibraries(ModuleChunk chunk) {
final Collection<JpsTypedLibrary<JpsSimpleElement<RepositoryLibraryDescriptor>>> result = new SmartHashSet<>();
for (JpsModule module : chunk.getModules()) {
for (JpsDependencyElement dep : module.getDependenciesList().getDependencies()) {
if (dep instanceof JpsLibraryDependency) {
final JpsLibrary _lib = ((JpsLibraryDependency) dep).getLibrary();
final JpsTypedLibrary<JpsSimpleElement<RepositoryLibraryDescriptor>> lib = _lib != null ? _lib.asTyped(JpsMavenRepositoryLibraryType.INSTANCE) : null;
if (lib != null) {
result.add(lib);
}
}
}
}
return result;
}
use of org.jetbrains.jps.model.JpsSimpleElement in project intellij-community by JetBrains.
the class JpsPluginSyntheticArtifactProvider method createArtifact.
private static JpsArtifact createArtifact(JpsModule module, JpsPluginModuleProperties properties) {
JpsPackagingElementFactory factory = JpsPackagingElementFactory.getInstance();
JpsCompositePackagingElement root = factory.createArtifactRoot();
String pluginXmlUrl = properties.getPluginXmlUrl();
if (pluginXmlUrl != null) {
String pluginXmlPath = JpsPathUtil.urlToPath(pluginXmlUrl);
JpsCompositePackagingElement metaInfDir = factory.getOrCreateDirectory(root, "META-INF");
metaInfDir.addChild(factory.createFileCopy(pluginXmlPath, null));
File pluginXmlFile = JpsPathUtil.urlToFile(pluginXmlUrl);
if (pluginXmlFile.exists()) {
try {
Element rootElement = JDOMUtil.load(pluginXmlFile);
for (Element dependsElement : JDOMUtil.getChildren(rootElement, "depends")) {
String relativePath = dependsElement.getAttributeValue("config-file");
if (relativePath != null) {
File dependencyFile = new File(pluginXmlFile.getParent(), FileUtil.toSystemDependentName(relativePath));
String dependencyPath = FileUtil.toSystemIndependentName(dependencyFile.getAbsolutePath());
metaInfDir.addChild(factory.createFileCopy(dependencyPath, null));
}
}
} catch (JDOMException | IOException e) {
LOG.info(e);
}
}
}
JpsJavaDependenciesEnumerator enumerator = JpsJavaExtensionService.dependencies(module).recursively().includedIn(JpsJavaClasspathKind.PRODUCTION_RUNTIME);
JpsCompositePackagingElement classesDir = factory.getOrCreateDirectory(root, "classes");
for (JpsModule depModule : enumerator.getModules()) {
if (depModule.getModuleType().equals(JpsJavaModuleType.INSTANCE)) {
classesDir.addChild(JpsJavaExtensionService.getInstance().createProductionModuleOutput(depModule.createReference()));
}
}
classesDir.addChild(JpsJavaExtensionService.getInstance().createProductionModuleOutput(module.createReference()));
for (JpsLibrary library : enumerator.getLibraries()) {
JpsCompositePackagingElement parent;
if (hasDirsOnly(library)) {
parent = classesDir;
} else {
parent = factory.getOrCreateDirectory(root, "lib");
}
parent.addChild(factory.createLibraryElement(library.createReference()));
}
String name = module.getName() + ":plugin";
JpsArtifact artifact = JpsArtifactService.getInstance().createArtifact(name, root, DirectoryArtifactType.INSTANCE, JpsElementFactory.getInstance().createDummyElement());
JpsSdk<JpsSimpleElement<JpsIdeaSdkProperties>> sdk = module.getSdk(JpsIdeaSdkType.INSTANCE);
if (sdk != null) {
String sandboxHome = sdk.getSdkProperties().getData().getSandboxHome();
if (sandboxHome != null) {
artifact.setOutputPath(sandboxHome + "/plugins/" + module.getName());
}
}
return artifact;
}
use of org.jetbrains.jps.model.JpsSimpleElement in project intellij-community by JetBrains.
the class JpsPluginProjectSerializationTest method testLoadProject.
public void testLoadProject() {
loadProject("plugins/devkit/jps-plugin/testData/pluginProject/pluginProject.ipr");
JpsModule module = assertOneElement(myProject.getModules());
assertEquals(JpsPluginModuleType.INSTANCE, module.getModuleType());
JpsTypedModule<JpsSimpleElement<JpsPluginModuleProperties>> pluginModule = module.asTyped(JpsPluginModuleType.INSTANCE);
assertNotNull(pluginModule);
String url = pluginModule.getProperties().getData().getPluginXmlUrl();
assertEquals(getUrl("META-INF/plugin.xml"), url);
JpsTypedLibrary<JpsSdk<JpsDummyElement>> javaSdk = myModel.getGlobal().addSdk("1.6", null, null, JpsJavaSdkType.INSTANCE);
JpsSimpleElement<JpsIdeaSdkProperties> properties = JpsElementFactory.getInstance().createSimpleElement(new JpsIdeaSdkProperties(null, "1.6"));
JpsTypedLibrary<JpsSdk<JpsSimpleElement<JpsIdeaSdkProperties>>> pluginSdk = myModel.getGlobal().addSdk("IDEA plugin SDK", null, null, JpsIdeaSdkType.INSTANCE, properties);
assertSame(pluginSdk.getProperties(), module.getSdk(JpsIdeaSdkType.INSTANCE));
assertSame(javaSdk.getProperties(), module.getSdk(JpsJavaSdkType.INSTANCE));
}
use of org.jetbrains.jps.model.JpsSimpleElement in project android by JetBrains.
the class AndroidJpsUtil method getAndroidPlatform.
@Nullable
public static AndroidPlatform getAndroidPlatform(@NotNull JpsModule module, @Nullable CompileContext context, String builderName) {
final JpsSdk<JpsSimpleElement<JpsAndroidSdkProperties>> sdk = module.getSdk(JpsAndroidSdkType.INSTANCE);
if (sdk == null) {
if (context != null) {
context.processMessage(new CompilerMessage(builderName, BuildMessage.Kind.ERROR, AndroidJpsBundle.message("android.jps.errors.sdk.not.specified", module.getName())));
}
return null;
}
final Pair<IAndroidTarget, AndroidSdkHandler> pair = getAndroidTarget(sdk, context, builderName);
if (pair == null) {
if (context != null) {
context.processMessage(new CompilerMessage(builderName, BuildMessage.Kind.ERROR, AndroidJpsBundle.message("android.jps.errors.sdk.invalid", module.getName())));
}
return null;
}
return new AndroidPlatform(sdk, pair.getFirst(), pair.getSecond());
}
use of org.jetbrains.jps.model.JpsSimpleElement 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);
}
Aggregations