use of org.jetbrains.jps.model.JpsElement in project intellij-community by JetBrains.
the class JpsLoaderBase method loadComponents.
protected <E extends JpsElement> void loadComponents(File dir, final String defaultFileName, JpsElementExtensionSerializerBase<E> serializer, final E element) {
String fileName = serializer.getConfigFileName();
File configFile = new File(dir, fileName != null ? fileName : defaultFileName);
Runnable timingLog = TimingLog.startActivity("loading: " + configFile.getName() + ":" + serializer.getComponentName());
Element componentTag;
if (configFile.exists()) {
componentTag = JDomSerializationUtil.findComponent(loadRootElement(configFile), serializer.getComponentName());
} else {
componentTag = null;
}
if (componentTag != null) {
serializer.loadExtension(element, componentTag);
} else {
serializer.loadExtensionWithDefaultSettings(element);
}
timingLog.run();
}
use of org.jetbrains.jps.model.JpsElement in project intellij-community by JetBrains.
the class JpsProjectLoader method createModule.
private static <P extends JpsElement> JpsModule createModule(String name, Element moduleRoot, JpsModulePropertiesSerializer<P> loader) {
String componentName = loader.getComponentName();
Element component = componentName != null ? JDomSerializationUtil.findComponent(moduleRoot, componentName) : null;
return JpsElementFactory.getInstance().createModule(name, loader.getType(), loader.loadProperties(component));
}
use of org.jetbrains.jps.model.JpsElement in project intellij-community by JetBrains.
the class JpsIdeaSpecificSettings method readContentEntry.
@Override
public void readContentEntry(Element root, String contentUrl, JpsModule model) {
for (Object o : root.getChildren(IdeaXml.TEST_FOLDER_TAG)) {
final String url = ((Element) o).getAttributeValue(IdeaXml.URL_ATTR);
JpsModuleSourceRoot folderToBeTest = null;
for (JpsModuleSourceRoot folder : model.getSourceRoots()) {
if (Comparing.strEqual(folder.getUrl(), url)) {
folderToBeTest = folder;
break;
}
}
if (folderToBeTest != null) {
model.removeSourceRoot(folderToBeTest.getUrl(), JavaSourceRootType.SOURCE);
}
model.addSourceRoot(url, JavaSourceRootType.TEST_SOURCE);
}
for (Object o : root.getChildren(IdeaXml.EXCLUDE_FOLDER_TAG)) {
final String excludeUrl = ((Element) o).getAttributeValue(IdeaXml.URL_ATTR);
if (FileUtil.isAncestor(new File(contentUrl), new File(excludeUrl), false)) {
model.getExcludeRootsList().addUrl(excludeUrl);
}
}
for (Object o : root.getChildren(IdeaXml.PACKAGE_PREFIX_TAG)) {
Element ppElement = (Element) o;
final String prefix = ppElement.getAttributeValue(IdeaXml.PACKAGE_PREFIX_VALUE_ATTR);
final String url = ppElement.getAttributeValue(IdeaXml.URL_ATTR);
for (JpsModuleSourceRoot sourceRoot : model.getSourceRoots()) {
if (Comparing.strEqual(sourceRoot.getUrl(), url)) {
JpsElement properties = sourceRoot.getProperties();
if (properties instanceof JavaSourceRootProperties) {
((JavaSourceRootProperties) properties).setPackagePrefix(prefix);
}
break;
}
}
}
}
use of org.jetbrains.jps.model.JpsElement in project android by JetBrains.
the class ContentEntriesSetup method addSourceFolder.
private static void addSourceFolder(@NotNull ContentEntry contentEntry, @NotNull File folderPath, @NotNull JpsModuleSourceRootType type, boolean generated) {
String url = pathToIdeaUrl(folderPath);
SourceFolder sourceFolder = contentEntry.addSourceFolder(url, type);
if (generated) {
JpsModuleSourceRoot sourceRoot = sourceFolder.getJpsElement();
JpsElement properties = sourceRoot.getProperties();
if (properties instanceof JavaSourceRootProperties) {
((JavaSourceRootProperties) properties).setForGeneratedSources(true);
}
}
}
use of org.jetbrains.jps.model.JpsElement in project android by JetBrains.
the class AndroidArtifactBuildTaskProvider method createArtifactBuildTasks.
@NotNull
@Override
public List<? extends BuildTask> createArtifactBuildTasks(@NotNull JpsArtifact artifact, @NotNull ArtifactBuildPhase buildPhase) {
if (buildPhase != ArtifactBuildPhase.FINISHING_BUILD) {
return Collections.emptyList();
}
if (!(artifact.getArtifactType() instanceof AndroidApplicationArtifactType)) {
return Collections.emptyList();
}
final JpsElement props = artifact.getProperties();
if (!(props instanceof JpsAndroidApplicationArtifactProperties)) {
return Collections.emptyList();
}
final JpsAndroidApplicationArtifactProperties androidProps = (JpsAndroidApplicationArtifactProperties) props;
if (!(artifact.getArtifactType() instanceof AndroidApplicationArtifactType)) {
return Collections.emptyList();
}
final AndroidArtifactSigningMode signingMode = androidProps.getSigningMode();
if (signingMode != AndroidArtifactSigningMode.RELEASE_SIGNED && signingMode != AndroidArtifactSigningMode.DEBUG_WITH_CUSTOM_CERTIFICATE) {
return Collections.emptyList();
}
final JpsAndroidModuleExtension extension = AndroidJpsUtil.getPackagedFacet(artifact);
return extension != null ? Collections.singletonList(new MyTask(artifact, extension, androidProps)) : Collections.<BuildTask>emptyList();
}
Aggregations