use of org.jetbrains.jps.model.JpsElement in project intellij-community by JetBrains.
the class MavenSourceFoldersModuleExtension method init.
public void init(@NotNull Module module, @NotNull ModifiableRootModel modifiableRootModel) {
myRootModel = modifiableRootModel;
myDummyJpsModule = JpsElementFactory.getInstance().createModule(module.getName(), JpsJavaModuleType.INSTANCE, JpsElementFactory.getInstance().createDummyElement());
myDummyJpsRootModel = new JpsRootModel(module, myDummyJpsModule);
for (JpsSourceFolder folder : myJpsSourceFolders) {
Disposer.dispose(folder);
}
myJpsSourceFolders.clear();
for (ContentEntry eachEntry : modifiableRootModel.getContentEntries()) {
for (SourceFolder eachFolder : eachEntry.getSourceFolders()) {
//noinspection unchecked
final JpsModuleSourceRoot jpsModuleSourceRoot = JpsElementFactory.getInstance().createModuleSourceRoot(eachFolder.getUrl(), (JpsModuleSourceRootType<JpsElement>) eachFolder.getRootType(), eachFolder.getJpsElement().getProperties().getBulkModificationSupport().createCopy());
addJspSourceFolder(jpsModuleSourceRoot, eachFolder.getUrl());
}
}
}
use of org.jetbrains.jps.model.JpsElement in project intellij-community by JetBrains.
the class MavenSourceFoldersModuleExtension method commit.
@Override
public void commit() {
if (!isJpsSourceFoldersChanged)
return;
for (ContentEntry eachEntry : myRootModel.getContentEntries()) {
for (SourceFolder eachFolder : eachEntry.getSourceFolders()) {
boolean found = false;
for (JpsSourceFolder jpsSourceFolder : myJpsSourceFolders) {
if (StringUtil.equals(jpsSourceFolder.getUrl(), eachFolder.getUrl()) && eachFolder.getRootType().equals(jpsSourceFolder.getRootType())) {
found = true;
if (eachFolder.getRootType() instanceof JavaSourceRootType) {
final JavaSourceRootProperties jpsJavaSourceRootProperties = jpsSourceFolder.getJpsElement().getProperties((JavaSourceRootType) eachFolder.getRootType());
final JavaSourceRootProperties javaSourceRootProperties = eachFolder.getJpsElement().getProperties((JavaSourceRootType) eachFolder.getRootType());
if (javaSourceRootProperties != null && jpsJavaSourceRootProperties != null) {
javaSourceRootProperties.applyChanges(jpsJavaSourceRootProperties);
}
}
myJpsSourceFolders.remove(jpsSourceFolder);
Disposer.dispose(jpsSourceFolder);
break;
}
}
if (!found) {
eachEntry.removeSourceFolder(eachFolder);
}
}
}
for (JpsSourceFolder jpsSourceFolder : myJpsSourceFolders) {
Url url = new Url(jpsSourceFolder.getUrl());
ContentEntry e = getContentRootFor(url);
if (e == null)
continue;
//noinspection unchecked
JpsModuleSourceRootType<JpsElement> sourceRootType = (JpsModuleSourceRootType<JpsElement>) jpsSourceFolder.getRootType();
final JpsElementBase properties = (JpsElementBase) jpsSourceFolder.getSourceRoot().getProperties();
//noinspection unchecked
properties.setParent(null);
e.addSourceFolder(url.getUrl(), sourceRootType, properties);
}
isJpsSourceFoldersChanged = false;
}
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 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();
}
use of org.jetbrains.jps.model.JpsElement 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