Search in sources :

Example 6 with JpsSdk

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

the class JavaBuilderUtil method ensureModuleHasJdk.

@NotNull
public static JpsSdk<JpsDummyElement> ensureModuleHasJdk(JpsModule module, CompileContext context, final String compilerName) throws ProjectBuildException {
    JpsSdkReference<JpsDummyElement> reference = module.getSdkReference(JpsJavaSdkType.INSTANCE);
    if (reference == null) {
        context.processMessage(new CompilerMessage(compilerName, BuildMessage.Kind.ERROR, "JDK isn't specified for module '" + module.getName() + "'"));
        throw new StopBuildException();
    }
    JpsTypedLibrary<JpsSdk<JpsDummyElement>> sdkLibrary = reference.resolve();
    if (sdkLibrary == null) {
        context.processMessage(new CompilerMessage(compilerName, BuildMessage.Kind.ERROR, "Cannot find JDK '" + reference.getSdkName() + "' for module '" + module.getName() + "'"));
        throw new StopBuildException();
    }
    return sdkLibrary.getProperties();
}
Also used : CompilerMessage(org.jetbrains.jps.incremental.messages.CompilerMessage) JpsDummyElement(org.jetbrains.jps.model.JpsDummyElement) JpsSdk(org.jetbrains.jps.model.library.sdk.JpsSdk) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

JpsSdk (org.jetbrains.jps.model.library.sdk.JpsSdk)6 File (java.io.File)2 NotNull (org.jetbrains.annotations.NotNull)2 JpsDummyElement (org.jetbrains.jps.model.JpsDummyElement)2 JpsModule (org.jetbrains.jps.model.module.JpsModule)2 Element (org.jdom.Element)1 CompilerMessage (org.jetbrains.jps.incremental.messages.CompilerMessage)1 JpsElement (org.jetbrains.jps.model.JpsElement)1 JpsSimpleElement (org.jetbrains.jps.model.JpsSimpleElement)1 JpsLibrary (org.jetbrains.jps.model.library.JpsLibrary)1