Search in sources :

Example 1 with JavaVersion

use of org.gradle.api.JavaVersion in project gradle by gradle.

the class CachingJvmVersionDetector method getJavaVersion.

@Override
public JavaVersion getJavaVersion(String javaCommand) {
    JavaVersion version = javaCmdResults.get(javaCommand);
    if (version != null) {
        return version;
    }
    version = delegate.getJavaVersion(javaCommand);
    javaCmdResults.put(javaCommand, version);
    return version;
}
Also used : JavaVersion(org.gradle.api.JavaVersion)

Example 2 with JavaVersion

use of org.gradle.api.JavaVersion in project gradle by gradle.

the class CachingJvmVersionDetector method getJavaVersion.

@Override
public JavaVersion getJavaVersion(JavaInfo jvm) {
    JavaVersion version = javaHomeResults.get(jvm);
    if (version != null) {
        return version;
    }
    version = delegate.getJavaVersion(jvm);
    javaHomeResults.put(jvm, version);
    return version;
}
Also used : JavaVersion(org.gradle.api.JavaVersion)

Example 3 with JavaVersion

use of org.gradle.api.JavaVersion in project gradle by gradle.

the class IdeaModelBuilder method appendModule.

private void appendModule(Map<String, DefaultIdeaModule> modules, IdeaModule ideaModule, DefaultIdeaProject ideaProject, DefaultGradleProject rootGradleProject) {
    DefaultIdeaContentRoot contentRoot = new DefaultIdeaContentRoot().setRootDirectory(ideaModule.getContentRoot()).setSourceDirectories(srcDirs(ideaModule.getSourceDirs(), ideaModule.getGeneratedSourceDirs())).setTestDirectories(srcDirs(ideaModule.getTestSourceDirs(), ideaModule.getGeneratedSourceDirs())).setExcludeDirectories(ideaModule.getExcludeDirs());
    Project project = ideaModule.getProject();
    DefaultIdeaModule defaultIdeaModule = new DefaultIdeaModule().setName(ideaModule.getName()).setParent(ideaProject).setGradleProject(rootGradleProject.findByPath(ideaModule.getProject().getPath())).setContentRoots(Collections.singletonList(contentRoot)).setJdkName(ideaModule.getJdkName()).setCompilerOutput(new DefaultIdeaCompilerOutput().setInheritOutputDirs(ideaModule.getInheritOutputDirs() != null ? ideaModule.getInheritOutputDirs() : false).setOutputDir(ideaModule.getOutputDir()).setTestOutputDir(ideaModule.getTestOutputDir()));
    JavaPluginConvention javaPluginConvention = project.getConvention().findPlugin(JavaPluginConvention.class);
    if (javaPluginConvention != null) {
        final IdeaLanguageLevel ideaModuleLanguageLevel = ideaModule.getLanguageLevel();
        JavaVersion moduleSourceLanguageLevel = convertIdeaLanguageLevelToJavaVersion(ideaModuleLanguageLevel);
        JavaVersion moduleTargetBytecodeVersion = ideaModule.getTargetBytecodeVersion();
        defaultIdeaModule.setJavaLanguageSettings(new DefaultIdeaJavaLanguageSettings().setSourceLanguageLevel(moduleSourceLanguageLevel).setTargetBytecodeVersion(moduleTargetBytecodeVersion));
    }
    modules.put(ideaModule.getName(), defaultIdeaModule);
}
Also used : DefaultIdeaContentRoot(org.gradle.plugins.ide.internal.tooling.idea.DefaultIdeaContentRoot) IdeaProject(org.gradle.plugins.ide.idea.model.IdeaProject) DefaultGradleProject(org.gradle.tooling.internal.gradle.DefaultGradleProject) Project(org.gradle.api.Project) DefaultIdeaProject(org.gradle.plugins.ide.internal.tooling.idea.DefaultIdeaProject) DefaultIdeaModule(org.gradle.plugins.ide.internal.tooling.idea.DefaultIdeaModule) JavaPluginConvention(org.gradle.api.plugins.JavaPluginConvention) DefaultIdeaJavaLanguageSettings(org.gradle.plugins.ide.internal.tooling.idea.DefaultIdeaJavaLanguageSettings) DefaultIdeaLanguageLevel(org.gradle.plugins.ide.internal.tooling.idea.DefaultIdeaLanguageLevel) IdeaLanguageLevel(org.gradle.plugins.ide.idea.model.IdeaLanguageLevel) JavaVersion(org.gradle.api.JavaVersion) DefaultIdeaCompilerOutput(org.gradle.plugins.ide.internal.tooling.idea.DefaultIdeaCompilerOutput)

Example 4 with JavaVersion

use of org.gradle.api.JavaVersion in project gradle by gradle.

the class JvmVersionValidator method validate.

public void validate(DaemonParameters parameters) {
    if (parameters.getEffectiveJvm().equals(Jvm.current())) {
        return;
    }
    JavaVersion javaVersion = versionDetector.getJavaVersion(parameters.getEffectiveJvm());
    UnsupportedJavaRuntimeException.assertUsingVersion("Gradle", JavaVersion.VERSION_1_8, javaVersion);
}
Also used : JavaVersion(org.gradle.api.JavaVersion)

Example 5 with JavaVersion

use of org.gradle.api.JavaVersion in project gradle by gradle.

the class IdeaModelBuilder method createModule.

private DefaultIdeaModule createModule(IdeaModule ideaModule, DefaultIdeaProject ideaProject, DefaultGradleProject rootGradleProject) {
    DefaultIdeaContentRoot contentRoot = new DefaultIdeaContentRoot().setRootDirectory(ideaModule.getContentRoot()).setSourceDirectories(srcDirs(ideaModule.getSourceDirs(), ideaModule.getGeneratedSourceDirs())).setTestDirectories(srcDirs(ideaModule.getTestSources().getFiles(), ideaModule.getGeneratedSourceDirs())).setResourceDirectories(srcDirs(ideaModule.getResourceDirs(), ideaModule.getGeneratedSourceDirs())).setTestResourceDirectories(srcDirs(ideaModule.getTestResources().getFiles(), ideaModule.getGeneratedSourceDirs())).setExcludeDirectories(ideaModule.getExcludeDirs());
    Project project = ideaModule.getProject();
    DefaultIdeaModule defaultIdeaModule = new DefaultIdeaModule().setName(ideaModule.getName()).setParent(ideaProject).setGradleProject(rootGradleProject.findByPath(ideaModule.getProject().getPath())).setContentRoots(Collections.singletonList(contentRoot)).setJdkName(ideaModule.getJdkName()).setCompilerOutput(new DefaultIdeaCompilerOutput().setInheritOutputDirs(ideaModule.getInheritOutputDirs() != null ? ideaModule.getInheritOutputDirs() : false).setOutputDir(ideaModule.getOutputDir()).setTestOutputDir(ideaModule.getTestOutputDir()));
    JavaPluginExtension javaPluginExtension = project.getExtensions().findByType(JavaPluginExtension.class);
    if (javaPluginExtension != null) {
        final IdeaLanguageLevel ideaModuleLanguageLevel = ideaModule.getLanguageLevel();
        JavaVersion moduleSourceLanguageLevel = convertIdeaLanguageLevelToJavaVersion(ideaModuleLanguageLevel);
        JavaVersion moduleTargetBytecodeVersion = ideaModule.getTargetBytecodeVersion();
        defaultIdeaModule.setJavaLanguageSettings(new DefaultIdeaJavaLanguageSettings().setSourceLanguageLevel(moduleSourceLanguageLevel).setTargetBytecodeVersion(moduleTargetBytecodeVersion));
    }
    buildDependencies(defaultIdeaModule, ideaModule);
    return defaultIdeaModule;
}
Also used : DefaultIdeaContentRoot(org.gradle.plugins.ide.internal.tooling.idea.DefaultIdeaContentRoot) IdeaProject(org.gradle.plugins.ide.idea.model.IdeaProject) Project(org.gradle.api.Project) DefaultIdeaProject(org.gradle.plugins.ide.internal.tooling.idea.DefaultIdeaProject) DefaultGradleProject(org.gradle.plugins.ide.internal.tooling.model.DefaultGradleProject) DefaultIdeaModule(org.gradle.plugins.ide.internal.tooling.idea.DefaultIdeaModule) DefaultIdeaJavaLanguageSettings(org.gradle.plugins.ide.internal.tooling.idea.DefaultIdeaJavaLanguageSettings) JavaPluginExtension(org.gradle.api.plugins.JavaPluginExtension) DefaultIdeaLanguageLevel(org.gradle.plugins.ide.internal.tooling.idea.DefaultIdeaLanguageLevel) IdeaLanguageLevel(org.gradle.plugins.ide.idea.model.IdeaLanguageLevel) JavaVersion(org.gradle.api.JavaVersion) DefaultIdeaCompilerOutput(org.gradle.plugins.ide.internal.tooling.idea.DefaultIdeaCompilerOutput)

Aggregations

JavaVersion (org.gradle.api.JavaVersion)11 IdeaLanguageLevel (org.gradle.plugins.ide.idea.model.IdeaLanguageLevel)5 File (java.io.File)4 IdeaProject (org.gradle.plugins.ide.idea.model.IdeaProject)4 Project (org.gradle.api.Project)3 ConventionMapping (org.gradle.api.internal.ConventionMapping)3 IdeaModule (org.gradle.plugins.ide.idea.model.IdeaModule)3 DefaultIdeaJavaLanguageSettings (org.gradle.plugins.ide.internal.tooling.idea.DefaultIdeaJavaLanguageSettings)3 DefaultIdeaLanguageLevel (org.gradle.plugins.ide.internal.tooling.idea.DefaultIdeaLanguageLevel)3 DefaultIdeaModule (org.gradle.plugins.ide.internal.tooling.idea.DefaultIdeaModule)3 DefaultIdeaProject (org.gradle.plugins.ide.internal.tooling.idea.DefaultIdeaProject)3 Map (java.util.Map)2 Set (java.util.Set)2 IConventionAware (org.gradle.api.internal.IConventionAware)2 JavaPluginExtension (org.gradle.api.plugins.JavaPluginExtension)2 DefaultIdeaCompilerOutput (org.gradle.plugins.ide.internal.tooling.idea.DefaultIdeaCompilerOutput)2 DefaultIdeaContentRoot (org.gradle.plugins.ide.internal.tooling.idea.DefaultIdeaContentRoot)2 Predicate (com.google.common.base.Predicate)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 Node (groovy.util.Node)1