Search in sources :

Example 36 with JpsLibrary

use of org.jetbrains.jps.model.library.JpsLibrary in project intellij-community by JetBrains.

the class JpsWrappedJavaSdkReferenceImpl method resolve.

@Nullable
@Override
public JpsTypedLibrary<JpsSdk<JpsDummyElement>> resolve() {
    JpsTypedLibrary<? extends JpsSdk<? extends JpsElement>> wrapper = myContainer.getChild(WRAPPER_ROLE).resolve();
    if (wrapper == null)
        return null;
    JpsModel model = getModel();
    if (model == null)
        return null;
    String sdkName = mySdkType.getJavaSdkName(wrapper.getProperties().getSdkProperties());
    if (sdkName == null)
        return null;
    JpsLibrary library = model.getGlobal().getLibraryCollection().findLibrary(sdkName);
    return library != null ? library.asTyped(JpsJavaSdkType.INSTANCE) : null;
}
Also used : JpsModel(org.jetbrains.jps.model.JpsModel) JpsLibrary(org.jetbrains.jps.model.library.JpsLibrary) Nullable(org.jetbrains.annotations.Nullable)

Example 37 with JpsLibrary

use of org.jetbrains.jps.model.library.JpsLibrary in project intellij-community by JetBrains.

the class JpsDependenciesEnumeratorTest method createJDomLibrary.

private JpsLibrary createJDomLibrary() {
    JpsLibrary library = addLibrary("jdom");
    library.addRoot(getJDomJar(), JpsOrderRootType.COMPILED);
    library.addRoot(getJDomSources(), JpsOrderRootType.SOURCES);
    return library;
}
Also used : JpsLibrary(org.jetbrains.jps.model.library.JpsLibrary)

Example 38 with JpsLibrary

use of org.jetbrains.jps.model.library.JpsLibrary in project intellij-community by JetBrains.

the class JpsEclipseClasspathReader method addJUnitDefaultLib.

@Override
protected void addJUnitDefaultLib(JpsModule rootModel, String junitName, ExpandMacroToPathMap macroMap) {
    final String ideaHome = macroMap.substitute("$APPLICATION_HOME_DIR$", SystemInfo.isFileSystemCaseSensitive);
    final FilenameFilter junitFilter = (dir, name) -> name.startsWith("junit");
    File[] junitJars = new File(ideaHome, "lib").listFiles(junitFilter);
    if (junitJars == null || junitJars.length == 0) {
        junitJars = new File(new File(ideaHome, "community"), "lib").listFiles(junitFilter);
    }
    if (junitJars != null && junitJars.length > 0) {
        final boolean isJUnit4 = junitName.contains("4");
        File junitJar = null;
        for (File jar : junitJars) {
            final boolean isCurrentJarV4 = jar.getName().contains("4");
            if (isCurrentJarV4 && isJUnit4 || !isCurrentJarV4 && !isJUnit4) {
                junitJar = jar;
                break;
            }
        }
        if (junitJar != null) {
            final JpsLibrary jpsLibrary = rootModel.addModuleLibrary(junitName, JpsJavaLibraryType.INSTANCE);
            jpsLibrary.addRoot(pathToUrl(junitJar.getPath()), JpsOrderRootType.COMPILED);
            final JpsDependenciesList dependenciesList = rootModel.getDependenciesList();
            dependenciesList.addLibraryDependency(jpsLibrary);
        }
    }
}
Also used : FilenameFilter(java.io.FilenameFilter) java.util(java.util) JpsOrderRootType(org.jetbrains.jps.model.library.JpsOrderRootType) StringUtil(com.intellij.openapi.util.text.StringUtil) ExpandMacroToPathMap(com.intellij.openapi.components.ExpandMacroToPathMap) org.jetbrains.jps.model.java(org.jetbrains.jps.model.java) HashSet(com.intellij.util.containers.HashSet) IOException(java.io.IOException) org.jetbrains.jps.model.module(org.jetbrains.jps.model.module) SystemInfo(com.intellij.openapi.util.SystemInfo) File(java.io.File) Nullable(org.jetbrains.annotations.Nullable) org.jetbrains.idea.eclipse(org.jetbrains.idea.eclipse) JpsLibraryReference(org.jetbrains.jps.model.library.JpsLibraryReference) JpsElementFactory(org.jetbrains.jps.model.JpsElementFactory) JpsLibraryTableSerializer(org.jetbrains.jps.model.serialization.library.JpsLibraryTableSerializer) Logger(com.intellij.openapi.diagnostic.Logger) Element(org.jdom.Element) JpsLibrary(org.jetbrains.jps.model.library.JpsLibrary) JpsMacroExpander(org.jetbrains.jps.model.serialization.JpsMacroExpander) FilenameFilter(java.io.FilenameFilter) File(java.io.File) JpsLibrary(org.jetbrains.jps.model.library.JpsLibrary)

Example 39 with JpsLibrary

use of org.jetbrains.jps.model.library.JpsLibrary in project intellij-community by JetBrains.

the class AppEngineEnhancerBuilderTest method addEnhancerLibrary.

private static void addEnhancerLibrary(JpsModule module) {
    String path = PathManager.getJarPathForClass(Enhance.class);
    JpsLibrary library = module.addModuleLibrary("appengine-enhancer", JpsJavaLibraryType.INSTANCE);
    library.addRoot(new File(path), JpsOrderRootType.COMPILED);
    module.getDependenciesList().addLibraryDependency(library);
}
Also used : JpsLibrary(org.jetbrains.jps.model.library.JpsLibrary) File(java.io.File)

Example 40 with JpsLibrary

use of org.jetbrains.jps.model.library.JpsLibrary in project intellij-elixir by KronicDeth.

the class BuilderTest method addElixirSdk.

private JpsSdk<SdkProperties> addElixirSdk(@NotNull JpsSdk erlangSdk) {
    JpsTypedLibrary<JpsSdk<SdkProperties>> elixirTypedLibrary = myModel.getGlobal().addSdk("Elixir " + elixirVersion(), elixirSdkHome(), elixirVersion(), Elixir.INSTANCE);
    HomePath.eachEbinPath(elixirSdkHome(), ebinPath -> elixirTypedLibrary.addRoot(JpsPathUtil.pathToUrl(ebinPath.toAbsolutePath().toString()), JpsOrderRootType.COMPILED));
    JpsLibrary erlangSdkLibrary = erlangSdk.getParent();
    elixirTypedLibrary.getProperties().getSdkProperties().setErlangSdkName(erlangSdkLibrary.getName());
    for (JpsLibraryRoot erlangLibraryRoot : erlangSdkLibrary.getRoots(JpsOrderRootType.COMPILED)) {
        elixirTypedLibrary.addRoot(erlangLibraryRoot.getUrl(), JpsOrderRootType.COMPILED);
    }
    return elixirTypedLibrary.getProperties();
}
Also used : JpsSdk(org.jetbrains.jps.model.library.sdk.JpsSdk) JpsLibrary(org.jetbrains.jps.model.library.JpsLibrary) JpsLibraryRoot(org.jetbrains.jps.model.library.JpsLibraryRoot)

Aggregations

JpsLibrary (org.jetbrains.jps.model.library.JpsLibrary)41 JpsModule (org.jetbrains.jps.model.module.JpsModule)11 File (java.io.File)10 Element (org.jdom.Element)8 NotNull (org.jetbrains.annotations.NotNull)7 JpsSimpleElement (org.jetbrains.jps.model.JpsSimpleElement)7 JpsLibraryRoot (org.jetbrains.jps.model.library.JpsLibraryRoot)6 JpsAndroidModuleExtensionImpl (org.jetbrains.jps.android.model.impl.JpsAndroidModuleExtensionImpl)5 JpsAndroidModuleProperties (org.jetbrains.jps.android.model.impl.JpsAndroidModuleProperties)5 JpsElement (org.jetbrains.jps.model.JpsElement)5 JpsDummyElement (org.jetbrains.jps.model.JpsDummyElement)4 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 Nullable (org.jetbrains.annotations.Nullable)3 JpsDependencyElement (org.jetbrains.jps.model.module.JpsDependencyElement)3 JpsLibraryDependency (org.jetbrains.jps.model.module.JpsLibraryDependency)3 Logger (com.intellij.openapi.diagnostic.Logger)2 SystemInfo (com.intellij.openapi.util.SystemInfo)2 JpsElementFactory (org.jetbrains.jps.model.JpsElementFactory)2 JpsSdkReference (org.jetbrains.jps.model.library.sdk.JpsSdkReference)2