当前位置: 首页>>代码示例>>Java>>正文


Java JavaPluginConvention类代码示例

本文整理汇总了Java中org.gradle.api.plugins.JavaPluginConvention的典型用法代码示例。如果您正苦于以下问题:Java JavaPluginConvention类的具体用法?Java JavaPluginConvention怎么用?Java JavaPluginConvention使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


JavaPluginConvention类属于org.gradle.api.plugins包,在下文中一共展示了JavaPluginConvention类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: apply

import org.gradle.api.plugins.JavaPluginConvention; //导入依赖的package包/类
public void apply(final Project project) {
    project.getPluginManager().apply(JavaBasePlugin.class);

    final OsgiPluginConvention osgiConvention = new OsgiPluginConvention((ProjectInternal) project);
    project.getConvention().getPlugins().put("osgi", osgiConvention);

    project.getPlugins().withType(JavaPlugin.class, new Action<JavaPlugin>() {
        @Override
        public void execute(JavaPlugin javaPlugin) {
            OsgiManifest osgiManifest = osgiConvention.osgiManifest();
            osgiManifest.setClassesDir(project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().getByName("main").getOutput().getClassesDir());
            osgiManifest.setClasspath(project.getConfigurations().getByName("runtime"));
            Jar jarTask = (Jar) project.getTasks().getByName("jar");
            jarTask.setManifest(osgiManifest);
        }
    });
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:18,代码来源:OsgiPlugin.java

示例2: configureScaladoc

import org.gradle.api.plugins.JavaPluginConvention; //导入依赖的package包/类
private static void configureScaladoc(final Project project, final ScalaRuntime scalaRuntime) {
    project.getTasks().withType(ScalaDoc.class, new Action<ScalaDoc>() {
        @Override
        public void execute(final ScalaDoc scalaDoc) {
            scalaDoc.getConventionMapping().map("destinationDir", new Callable<File>() {
                @Override
                public File call() throws Exception {
                    File docsDir = project.getConvention().getPlugin(JavaPluginConvention.class).getDocsDir();
                    return project.file(docsDir.getPath() + "/scaladoc");
                }
            });
            scalaDoc.getConventionMapping().map("title", new Callable<String>() {
                @Override
                public String call() throws Exception {
                    return project.getExtensions().getByType(ReportingExtension.class).getApiDocTitle();
                }
            });
            scalaDoc.getConventionMapping().map("scalaClasspath", new Callable<FileCollection>() {
                @Override
                public FileCollection call() throws Exception {
                    return scalaRuntime.inferScalaClasspath(scalaDoc.getClasspath());
                }
            });
        }
    });
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:27,代码来源:ScalaBasePlugin.java

示例3: configureDev

import org.gradle.api.plugins.JavaPluginConvention; //导入依赖的package包/类
private void configureDev(Project project, JavaPluginConvention javaConvention) {
  SourceSet main = javaConvention.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME);
  SourceSet test = javaConvention.getSourceSets().getByName(SourceSet.TEST_SOURCE_SET_NAME);
  SourceSet dev = javaConvention.getSourceSets().create(DEV_SOURCE_SET_NAME);
  dev.setCompileClasspath(project.files(test.getOutput(), main.getOutput(), project.getConfigurations().getByName(dev.getCompileClasspathConfigurationName())));
  dev.setRuntimeClasspath(project.files(dev.getAllSource().getSourceDirectories(), test.getAllSource().getSourceDirectories(), main.getAllSource().getSourceDirectories(), project.getConfigurations().getByName(dev.getRuntimeClasspathConfigurationName())));

  Stream.<Function<SourceSet, String>>of(SourceSet::getCompileConfigurationName, SourceSet::getImplementationConfigurationName, SourceSet::getRuntimeConfigurationName, SourceSet::getRuntimeOnlyConfigurationName).forEach(getter -> {
    Configuration devConf = project.getConfigurations().getByName(getter.apply(dev));
    Configuration testConf = project.getConfigurations().getByName(getter.apply(test));
    devConf.extendsFrom(testConf);
  });

  project.getTasks().create("clojureRepl", ClojureNRepl.class, task -> {
    task.setGroup("run");
    task.setDescription("Starts an nREPL server.");
    task.setClasspath(dev.getRuntimeClasspath());
  });
}
 
开发者ID:gradle-clojure,项目名称:gradle-clojure,代码行数:20,代码来源:ClojurePlugin.java

示例4: registerInSourceSets

import org.gradle.api.plugins.JavaPluginConvention; //导入依赖的package包/类
public void registerInSourceSets(String ...sourceSetNames) {
    if (sourceSetNames == null || sourceSetNames.length == 0) return;

    try {
        JavaPluginConvention javaPlugin = getProject().getConvention().getPlugin(JavaPluginConvention.class);
        if (javaPlugin == null) {
            throw new GradleException("You must apply the java plugin if you're using 'registerInSourceSets' functionality.");
        }

        for (String sourceSet : sourceSetNames) {
            javaPlugin.getSourceSets().getByName(sourceSet).getOutput().dir(
                    Collections.singletonMap("builtBy", this),
                    getOutDir()
            );
        }
    } catch (Exception e) {
        throw new GradleException("You must apply the java plugin if you're using 'registerInSourceSets' functionality.");
    }
}
 
开发者ID:kravemir,项目名称:GradleSassPlugin,代码行数:20,代码来源:SassCompileTask.java

示例5: apply

import org.gradle.api.plugins.JavaPluginConvention; //导入依赖的package包/类
@Override
public void apply(final Project project) {
	Logger logger = project.getLogger();
	logger.info("applying jsweet plugin");

	if (!project.getPlugins().hasPlugin(JavaPlugin.class) && !project.getPlugins().hasPlugin(WarPlugin.class)) {
		logger.error("No java or war plugin detected. Enable java or war plugin.");
		throw new IllegalStateException("No java or war plugin detected. Enable java or war plugin.");
	}

	JSweetPluginExtension extension = project.getExtensions().create("jsweet", JSweetPluginExtension.class);

	JavaPluginConvention javaPluginConvention = project.getConvention().getPlugin(JavaPluginConvention.class);
	SourceSetContainer sourceSets = javaPluginConvention.getSourceSets();
	SourceSet mainSources = sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME);

	JSweetTranspileTask task = project.getTasks().create("jsweet", JSweetTranspileTask.class);
	task.setGroup("generate");
	task.dependsOn(JavaPlugin.COMPILE_JAVA_TASK_NAME);
	task.setConfiguration(extension);
	task.setSources(mainSources.getAllJava());
	task.setClasspath(mainSources.getCompileClasspath());
	
	JSweetCleanTask cleanTask = project.getTasks().create("jsweetClean", JSweetCleanTask.class);
	cleanTask.setConfiguration(extension);
}
 
开发者ID:lgrignon,项目名称:jsweet-gradle-plugin,代码行数:27,代码来源:JSweetPlugin.java

示例6: listProjectDepsSrcDirs

import org.gradle.api.plugins.JavaPluginConvention; //导入依赖的package包/类
private Collection<File> listProjectDepsSrcDirs(Project project) {
	ConfigurationContainer configs = project.getConfigurations();
	Configuration compileConf = configs.getByName(JavaPlugin.COMPILE_CLASSPATH_CONFIGURATION_NAME);
	DependencySet depSet = compileConf.getAllDependencies();

	List<File> result = Lists.newArrayList();
	for (Dependency dep : depSet) {
		if (dep instanceof ProjectDependency) {
			Project projectDependency = ((ProjectDependency) dep).getDependencyProject();
			if (projectDependency.getPlugins().hasPlugin(PwtLibPlugin.class)) {
				JavaPluginConvention javaConvention = projectDependency.getConvention().getPlugin(JavaPluginConvention.class);
				SourceSet mainSourceSet = javaConvention.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME);

				result.addAll(mainSourceSet.getAllSource().getSrcDirs());
			}
		}
	}
	return result;
}
 
开发者ID:Putnami,项目名称:putnami-gradle-plugin,代码行数:20,代码来源:CodeServerBuilder.java

示例7: EnunciateTask

import org.gradle.api.plugins.JavaPluginConvention; //导入依赖的package包/类
public EnunciateTask() {
	log = getLogger();

	classpathConfigName = getProject().getObjects().property(String.class);
	classpathConfigName.set("compileClasspath");
	
	javaPluginConvention = getProject().getConvention().findPlugin(JavaPluginConvention.class);

	dependsOn(getProject().getTasks().getByName("classes"));
	
	mainSourceSet = javaPluginConvention.getSourceSets().findByName("main");
	sourcePath = getProject().files();
	
	getInputs().files(lazyGetMatchingSourceFiles());
	getInputs().file(lazyGetConfigFile());
	getOutputs().dir(lazyGetBuildDir());
}
 
开发者ID:stoicflame,项目名称:enunciate-gradle,代码行数:18,代码来源:EnunciateTask.java

示例8: buildCompilerArgs

import org.gradle.api.plugins.JavaPluginConvention; //导入依赖的package包/类
private List<String> buildCompilerArgs(JavaPluginConvention javaPluginConvention) {
	TaskCollection<JavaCompile> javaCompilers = getProject().getTasks().withType(JavaCompile.class);
	CompileOptions firstCompilerOptions = javaCompilers.isEmpty() ? null : javaCompilers.iterator().next().getOptions();
	
	List<String> args = new ArrayList<>(Arrays.asList("-source", javaPluginConvention.getSourceCompatibility().toString(),
						 							  "-target", javaPluginConvention.getTargetCompatibility().toString(),
						 							  "-encoding", getDefaultOrCompilerEncoding(firstCompilerOptions)));

	if (firstCompilerOptions != null) {
		FileCollection bootClasspath = firstCompilerOptions.getBootstrapClasspath();
		if (bootClasspath != null) {
			args.add("-bootclasspath");
			args.add(bootClasspath.getAsPath());
		}
	}
	
	return args;
}
 
开发者ID:stoicflame,项目名称:enunciate-gradle,代码行数:19,代码来源:EnunciateTask.java

示例9: setupTask

import org.gradle.api.plugins.JavaPluginConvention; //导入依赖的package包/类
/** If the user hasn't specified the files yet, we'll assume he/she means all of the kotlin files. */
@Override
protected void setupTask(SpotlessTask task) {
	if (target == null) {
		JavaPluginConvention javaPlugin = getProject().getConvention().findPlugin(JavaPluginConvention.class);
		if (javaPlugin == null) {
			throw new GradleException("You must either specify 'target' manually or apply a kotlin plugin.");
		}
		FileCollection union = getProject().files();
		for (SourceSet sourceSet : javaPlugin.getSourceSets()) {
			union = union.plus(sourceSet.getAllSource().filter(file -> {
				String name = file.getName();
				return name.endsWith(".kt") || name.endsWith(".kts");
			}));
		}
		target = union;
	}
	super.setupTask(task);
}
 
开发者ID:diffplug,项目名称:spotless,代码行数:20,代码来源:KotlinExtension.java

示例10: setupTask

import org.gradle.api.plugins.JavaPluginConvention; //导入依赖的package包/类
/** If the user hasn't specified the files yet, we'll assume he/she means all of the java files. */
@Override
protected void setupTask(SpotlessTask task) {
	if (target == null) {
		JavaPluginConvention javaPlugin = getProject().getConvention().findPlugin(JavaPluginConvention.class);
		if (javaPlugin == null) {
			throw new GradleException("You must apply the java plugin before the spotless plugin if you are using the java extension.");
		}
		FileCollection union = getProject().files();
		for (SourceSet sourceSet : javaPlugin.getSourceSets()) {
			union = union.plus(sourceSet.getAllJava());
		}
		target = union;
	}
	// LicenseHeaderStep completely blows apart package-info.java - this common-sense check ensures that
	// it skips package-info.java. See https://github.com/diffplug/spotless/issues/1
	steps.replaceAll(step -> {
		if (LicenseHeaderStep.name().equals(step.getName())) {
			return step.filterByFile(SerializableFileFilter.skipFilesNamed("package-info.java"));
		} else {
			return step;
		}
	});
	super.setupTask(task);
}
 
开发者ID:diffplug,项目名称:spotless,代码行数:26,代码来源:JavaExtension.java

示例11: setupTask

import org.gradle.api.plugins.JavaPluginConvention; //导入依赖的package包/类
/** If the user hasn't specified the files yet, we'll assume he/she means all of the kotlin files. */
@Override
protected void setupTask(SpotlessTask task) {
	if (target == null) {
		JavaPluginConvention javaPlugin = getProject().getConvention().findPlugin(JavaPluginConvention.class);
		if (javaPlugin == null) {
			throw new GradleException("You must either specify 'target' manually or apply the 'scala' plugin.");
		}
		FileCollection union = getProject().files();
		for (SourceSet sourceSet : javaPlugin.getSourceSets()) {
			union = union.plus(sourceSet.getAllSource().filter(file -> {
				String name = file.getName();
				return name.endsWith(".scala") || name.endsWith(".sc");
			}));
		}
		target = union;
	}
	super.setupTask(task);
}
 
开发者ID:diffplug,项目名称:spotless,代码行数:20,代码来源:ScalaExtension.java

示例12: configureFor

import org.gradle.api.plugins.JavaPluginConvention; //导入依赖的package包/类
@Override
public void configureFor(@Nonnull final DependencyConfig pDepConfig)
{
    final Project project = getProject();
    final JavaVersion javaLevel = pDepConfig.getJavaLevel();

    setDescription(
        buildUtil.getLongName() + ": Generate Javadoc API documentation for dependency configuration '" + pDepConfig
            .getName() + "' (Java level: " + javaLevel + ")");
    dependsOn(buildUtil.getTask(TaskNames.compileJava, pDepConfig));

    final JavaPluginConvention javaConvention = project.getConvention().getPlugin(JavaPluginConvention.class);
    setDestinationDir(new File(javaConvention.getDocsDir(), getName()));

    configureJavadocTask(this, pDepConfig);

    final JavaLevelUtil javaLevelUtil = new JavaLevelUtil(project);
    if (javaLevelUtil.isOlderSupportedJava(javaLevel)) {
        setExecutable(javaLevelUtil.getJavadocExecutable(javaLevel));
    }
}
 
开发者ID:checkstyle-addons,项目名称:checkstyle-addons,代码行数:22,代码来源:JavadocTask.java

示例13: establishSonarQubeSourceSet

import org.gradle.api.plugins.JavaPluginConvention; //导入依赖的package包/类
public void establishSonarQubeSourceSet()
{
    final JavaPluginConvention javaConvention = project.getConvention().getPlugin(JavaPluginConvention.class);
    final SourceSetContainer sourceSets = javaConvention.getSourceSets();
    final ConfigurationContainer configs = project.getConfigurations();

    final SourceSet testSourceSet = sourceSets.getByName(SourceSet.TEST_SOURCE_SET_NAME);
    final SourceSet sqSourceSet = sourceSets.create(BuildUtil.SONARQUBE_SOURCE_SET_NAME);

    configs.getByName(testSourceSet.getImplementationConfigurationName()).extendsFrom(
        configs.getByName(sqSourceSet.getImplementationConfigurationName()));
    configs.getByName(testSourceSet.getRuntimeOnlyConfigurationName()).extendsFrom(
        configs.getByName(sqSourceSet.getRuntimeOnlyConfigurationName()));

    final TaskContainer tasks = project.getTasks();
    tasks.getByName(JavaPlugin.COMPILE_TEST_JAVA_TASK_NAME).dependsOn(
        tasks.getByName(sqSourceSet.getClassesTaskName()));

    final FileCollection sqOutputs = sqSourceSet.getOutput().getClassesDirs().plus(
        project.files(sqSourceSet.getOutput().getResourcesDir()));
    testSourceSet.setCompileClasspath(testSourceSet.getCompileClasspath().plus(sqOutputs));
    testSourceSet.setRuntimeClasspath(testSourceSet.getRuntimeClasspath().plus(sqOutputs));
}
 
开发者ID:checkstyle-addons,项目名称:checkstyle-addons,代码行数:24,代码来源:TaskCreator.java

示例14: configureWithJavaPluginApplied

import org.gradle.api.plugins.JavaPluginConvention; //导入依赖的package包/类
private void configureWithJavaPluginApplied(final Project project, final EarPluginConvention earPluginConvention, PluginContainer plugins) {
    plugins.withType(JavaPlugin.class, new Action<JavaPlugin>() {
        public void execute(JavaPlugin javaPlugin) {
            final JavaPluginConvention javaPluginConvention = project.getConvention().findPlugin(JavaPluginConvention.class);

            SourceSet sourceSet = javaPluginConvention.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME);
            sourceSet.getResources().srcDir(new Callable() {
                public Object call() throws Exception {
                    return earPluginConvention.getAppDirName();
                }
            });
            project.getTasks().withType(Ear.class, new Action<Ear>() {
                public void execute(final Ear task) {
                    task.dependsOn(new Callable<FileCollection>() {
                        public FileCollection call() throws Exception {
                            return javaPluginConvention.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME)
                                    .getRuntimeClasspath();
                        }
                    });
                    task.from(new Callable<FileCollection>() {
                        public FileCollection call() throws Exception {
                            return javaPluginConvention.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME).getOutput();
                        }
                    });
                }
            });
        }
    });
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:30,代码来源:EarPlugin.java

示例15: configureSourceSetDefaults

import org.gradle.api.plugins.JavaPluginConvention; //导入依赖的package包/类
private static void configureSourceSetDefaults(final Project project, final SourceDirectorySetFactory sourceDirectorySetFactory) {
    final JavaBasePlugin javaPlugin = project.getPlugins().getPlugin(JavaBasePlugin.class);
    project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().all(new Action<SourceSet>() {
        @Override
        public void execute(final SourceSet sourceSet) {
            String displayName = (String) InvokerHelper.invokeMethod(sourceSet, "getDisplayName", null);
            Convention sourceSetConvention = (Convention) InvokerHelper.getProperty(sourceSet, "convention");
            DefaultScalaSourceSet scalaSourceSet = new DefaultScalaSourceSet(displayName, sourceDirectorySetFactory);
            sourceSetConvention.getPlugins().put("scala", scalaSourceSet);
            final SourceDirectorySet scalaDirectorySet = scalaSourceSet.getScala();
            scalaDirectorySet.srcDir(new Callable<File>() {
                @Override
                public File call() throws Exception {
                    return project.file("src/" + sourceSet.getName() + "/scala");
                }
            });
            sourceSet.getAllJava().source(scalaDirectorySet);
            sourceSet.getAllSource().source(scalaDirectorySet);
            sourceSet.getResources().getFilter().exclude(new Spec<FileTreeElement>() {
                @Override
                public boolean isSatisfiedBy(FileTreeElement element) {
                    return scalaDirectorySet.contains(element.getFile());
                }
            });

            configureScalaCompile(project, javaPlugin, sourceSet);
        }

    });
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:31,代码来源:ScalaBasePlugin.java


注:本文中的org.gradle.api.plugins.JavaPluginConvention类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。