use of org.jetbrains.jps.model.artifact.JpsArtifact in project intellij-community by JetBrains.
the class MavenEjbArtifactRootCopyingHandlerProvider method createCustomHandler.
@Nullable
@Override
public FileCopyingHandler createCustomHandler(@NotNull JpsArtifact artifact, @NotNull File root, @NotNull JpsPackagingElement contextElement, @NotNull JpsModel model, @NotNull BuildDataPaths buildDataPaths) {
MavenProjectConfiguration projectConfiguration = JpsMavenExtensionService.getInstance().getMavenProjectConfiguration(buildDataPaths);
if (projectConfiguration == null)
return null;
MavenEjbClientConfiguration ejbCfg = projectConfiguration.ejbClientArtifactConfigs.get(artifact.getName());
if (ejbCfg == null) {
JpsArtifact parentArtifact = findParentArtifact(contextElement);
if (parentArtifact != null) {
ejbCfg = projectConfiguration.ejbClientArtifactConfigs.get(parentArtifact.getName());
}
}
return ejbCfg == null ? null : new FilterCopyHandler(new MavenResourceFileFilter(root, ejbCfg));
}
use of org.jetbrains.jps.model.artifact.JpsArtifact 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.artifact.JpsArtifact in project intellij-community by JetBrains.
the class JpsAntSerializationTest method testLoadArtifactProperties.
public void testLoadArtifactProperties() {
loadProject(PROJECT_PATH);
List<JpsArtifact> artifacts = JpsArtifactService.getInstance().getSortedArtifacts(myProject);
assertEquals(2, artifacts.size());
JpsArtifact dir = artifacts.get(0);
assertEquals("dir", dir.getName());
JpsAntArtifactExtension preprocessing = JpsAntExtensionService.getPreprocessingExtension(dir);
assertNotNull(preprocessing);
assertTrue(preprocessing.isEnabled());
assertEquals(getUrl("build.xml"), preprocessing.getFileUrl());
assertEquals("show-message", preprocessing.getTargetName());
assertEquals(JpsAntArtifactExtensionImpl.ARTIFACT_OUTPUT_PATH_PROPERTY, assertOneElement(preprocessing.getAntProperties()).getPropertyName());
JpsAntArtifactExtension postprocessing = JpsAntExtensionService.getPostprocessingExtension(dir);
assertNotNull(postprocessing);
assertEquals(getUrl("build.xml"), postprocessing.getFileUrl());
assertEquals("create-file", postprocessing.getTargetName());
List<BuildFileProperty> properties = postprocessing.getAntProperties();
assertEquals(2, properties.size());
assertEquals(JpsAntArtifactExtensionImpl.ARTIFACT_OUTPUT_PATH_PROPERTY, properties.get(0).getPropertyName());
assertEquals(dir.getOutputPath(), properties.get(0).getPropertyValue());
assertEquals("message.text", properties.get(1).getPropertyName());
assertEquals("post", properties.get(1).getPropertyValue());
JpsArtifact jar = artifacts.get(1);
assertEquals("jar", jar.getName());
assertNull(JpsAntExtensionService.getPostprocessingExtension(jar));
assertNull(JpsAntExtensionService.getPreprocessingExtension(jar));
}
use of org.jetbrains.jps.model.artifact.JpsArtifact in project intellij-community by JetBrains.
the class ArtifactBuildTarget method computeRootDescriptors.
@NotNull
@Override
public List<ArtifactRootDescriptor> computeRootDescriptors(JpsModel model, ModuleExcludeIndex index, IgnoredFileIndex ignoredFileIndex, BuildDataPaths dataPaths) {
ArtifactInstructionsBuilderImpl builder = new ArtifactInstructionsBuilderImpl(index, ignoredFileIndex, this, model, dataPaths);
ArtifactInstructionsBuilderContext context = new ArtifactInstructionsBuilderContextImpl(model, dataPaths);
final JpsArtifact artifact = getArtifact();
String outputPath = StringUtil.notNullize(artifact.getOutputPath());
final CopyToDirectoryInstructionCreator instructionCreator = new CopyToDirectoryInstructionCreator(builder, outputPath);
LayoutElementBuildersRegistry.getInstance().generateInstructions(artifact, instructionCreator, context);
return builder.getDescriptors();
}
use of org.jetbrains.jps.model.artifact.JpsArtifact in project android by JetBrains.
the class AndroidJpsUtil method getProGuardConfigIfShouldRun.
public static ProGuardOptions getProGuardConfigIfShouldRun(@NotNull CompileContext context, @NotNull JpsAndroidModuleExtension extension) throws IOException {
if (extension.isRunProguard()) {
return new ProGuardOptions(extension.getProguardConfigFiles(extension.getModule()));
}
final String cfgPathsStrFromContext = context.getBuilderParameter(AndroidCommonUtils.PROGUARD_CFG_PATHS_OPTION);
if (cfgPathsStrFromContext != null && cfgPathsStrFromContext.length() > 0) {
final String[] paths = cfgPathsStrFromContext.split(File.pathSeparator);
if (paths.length > 0) {
final File[] files = toFiles(paths);
return new ProGuardOptions(Arrays.asList(files));
}
}
for (JpsArtifact artifact : getAndroidArtifactsToBuild(context)) {
final JpsAndroidModuleExtension facetFromArtifact = getPackagedFacet(artifact);
final JpsModule moduleFromArtifact = facetFromArtifact != null ? facetFromArtifact.getModule() : null;
if (moduleFromArtifact != null && moduleFromArtifact.equals(extension.getModule())) {
final JpsElement props = artifact.getProperties();
if (props instanceof JpsAndroidApplicationArtifactProperties) {
final JpsAndroidApplicationArtifactProperties androidProps = (JpsAndroidApplicationArtifactProperties) props;
if (androidProps.isRunProGuard()) {
final List<String> cfgFileUrls = androidProps.getProGuardCfgFiles(moduleFromArtifact);
final List<File> cfgPaths = cfgFileUrls != null ? urlsToFiles(cfgFileUrls) : null;
return new ProGuardOptions(cfgPaths);
}
}
}
}
return null;
}
Aggregations