Search in sources :

Example 6 with JpsElement

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();
}
Also used : JpsElement(org.jetbrains.jps.model.JpsElement) Element(org.jdom.Element) File(java.io.File)

Example 7 with JpsElement

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));
}
Also used : JpsElement(org.jetbrains.jps.model.JpsElement) JpsDummyElement(org.jetbrains.jps.model.JpsDummyElement) Element(org.jdom.Element)

Example 8 with JpsElement

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;
            }
        }
    }
}
Also used : JpsModuleSourceRoot(org.jetbrains.jps.model.module.JpsModuleSourceRoot) JpsElement(org.jetbrains.jps.model.JpsElement) JpsElement(org.jetbrains.jps.model.JpsElement) Element(org.jdom.Element) File(java.io.File)

Example 9 with JpsElement

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);
        }
    }
}
Also used : SourceFolder(com.intellij.openapi.roots.SourceFolder) JpsModuleSourceRoot(org.jetbrains.jps.model.module.JpsModuleSourceRoot) JpsElement(org.jetbrains.jps.model.JpsElement) JavaSourceRootProperties(org.jetbrains.jps.model.java.JavaSourceRootProperties)

Example 10 with JpsElement

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();
}
Also used : JpsElement(org.jetbrains.jps.model.JpsElement) JpsAndroidModuleExtension(org.jetbrains.jps.android.model.JpsAndroidModuleExtension) JpsAndroidApplicationArtifactProperties(org.jetbrains.jps.android.model.JpsAndroidApplicationArtifactProperties) AndroidApplicationArtifactType(org.jetbrains.jps.android.model.AndroidApplicationArtifactType) AndroidArtifactSigningMode(org.jetbrains.android.compiler.artifact.AndroidArtifactSigningMode) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

JpsElement (org.jetbrains.jps.model.JpsElement)15 Element (org.jdom.Element)7 JpsDummyElement (org.jetbrains.jps.model.JpsDummyElement)4 JpsAndroidApplicationArtifactProperties (org.jetbrains.jps.android.model.JpsAndroidApplicationArtifactProperties)3 JpsModuleSourceRoot (org.jetbrains.jps.model.module.JpsModuleSourceRoot)3 JpsContentEntry (com.intellij.project.model.impl.module.content.JpsContentEntry)2 JpsSourceFolder (com.intellij.project.model.impl.module.content.JpsSourceFolder)2 File (java.io.File)2 AndroidArtifactSigningMode (org.jetbrains.android.compiler.artifact.AndroidArtifactSigningMode)2 NotNull (org.jetbrains.annotations.NotNull)2 JpsAndroidModuleExtension (org.jetbrains.jps.android.model.JpsAndroidModuleExtension)2 JpsArtifact (org.jetbrains.jps.model.artifact.JpsArtifact)2 JavaSourceRootProperties (org.jetbrains.jps.model.java.JavaSourceRootProperties)2 JpsLibrary (org.jetbrains.jps.model.library.JpsLibrary)2 SourceFolder (com.intellij.openapi.roots.SourceFolder)1 JpsRootModel (com.intellij.project.model.impl.module.JpsRootModel)1 HashMap (com.intellij.util.containers.HashMap)1 HashSet (com.intellij.util.containers.HashSet)1 THashSet (gnu.trove.THashSet)1 TObjectLongHashMap (gnu.trove.TObjectLongHashMap)1