use of org.gradle.api.plugins.JavaPluginConvention 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);
}
use of org.gradle.api.plugins.JavaPluginConvention in project flyway by flyway.
the class AbstractFlywayTask method runTask.
@TaskAction
public Object runTask() {
try {
List<URL> extraURLs = new ArrayList<URL>();
if (isJavaProject()) {
JavaPluginConvention plugin = getProject().getConvention().getPlugin(JavaPluginConvention.class);
for (SourceSet sourceSet : plugin.getSourceSets()) {
URL classesUrl = sourceSet.getOutput().getClassesDir().toURI().toURL();
getLogger().debug("Adding directory to Classpath: " + classesUrl);
extraURLs.add(classesUrl);
URL resourcesUrl = sourceSet.getOutput().getResourcesDir().toURI().toURL();
getLogger().debug("Adding directory to Classpath: " + resourcesUrl);
extraURLs.add(resourcesUrl);
}
addDependenciesWithScope(extraURLs, "compile");
addDependenciesWithScope(extraURLs, "runtime");
addDependenciesWithScope(extraURLs, "testCompile");
addDependenciesWithScope(extraURLs, "testRuntime");
}
ClassLoader classLoader = new URLClassLoader(extraURLs.toArray(new URL[extraURLs.size()]), getProject().getBuildscript().getClassLoader());
Flyway flyway = new Flyway();
flyway.setClassLoader(classLoader);
flyway.configure(createFlywayConfig());
return run(flyway);
} catch (Exception e) {
handleException(e);
return null;
}
}
use of org.gradle.api.plugins.JavaPluginConvention in project gradle by gradle.
the class JavaGradlePluginPlugin method createExtension.
private GradlePluginDevelopmentExtension createExtension(Project project) {
JavaPluginConvention javaConvention = project.getConvention().getPlugin(JavaPluginConvention.class);
SourceSet defaultPluginSourceSet = javaConvention.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME);
SourceSet defaultTestSourceSet = javaConvention.getSourceSets().getByName(SourceSet.TEST_SOURCE_SET_NAME);
return project.getExtensions().create(EXTENSION_NAME, GradlePluginDevelopmentExtension.class, project, defaultPluginSourceSet, defaultTestSourceSet);
}
use of org.gradle.api.plugins.JavaPluginConvention in project spring-boot by spring-projects.
the class RunPluginFeatures method addBootRunTask.
private void addBootRunTask(final Project project) {
final JavaPluginConvention javaConvention = project.getConvention().getPlugin(JavaPluginConvention.class);
BootRunTask run = project.getTasks().create(RUN_APP_TASK_NAME, BootRunTask.class);
run.setDescription("Run the project with support for " + "auto-detecting main class and reloading static resources");
run.setGroup("application");
run.setClasspath(javaConvention.getSourceSets().findByName("main").getRuntimeClasspath());
run.getConventionMapping().map("main", new Callable<Object>() {
@Override
public Object call() throws Exception {
if (project.hasProperty("mainClassName") && project.property("mainClassName") != null) {
return project.property("mainClassName");
}
ExtraPropertiesExtension extraPropertiesExtension = (ExtraPropertiesExtension) project.getExtensions().getByName("ext");
if (extraPropertiesExtension.has("mainClassName") && extraPropertiesExtension.get("mainClassName") != null) {
return extraPropertiesExtension.get("mainClassName");
}
return null;
}
});
run.getConventionMapping().map("jvmArgs", new Callable<Object>() {
@Override
public Object call() throws Exception {
if (project.hasProperty("applicationDefaultJvmArgs")) {
return project.property("applicationDefaultJvmArgs");
}
return Collections.emptyList();
}
});
}
Aggregations