本文整理了Java中org.gradle.api.plugins.Convention
类的一些代码示例,展示了Convention
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Convention
类的具体详情如下:
包路径:org.gradle.api.plugins.Convention
类名称:Convention
暂无
代码示例来源:origin: jooby-project/jooby
public JavaPluginConvention getJavaConvention(final Project project) {
return project.getConvention().getPlugin(JavaPluginConvention.class);
}
代码示例来源:origin: io.github.gradle-clojure/gradle-clojure-plugin
@Override
public void apply(Project project) {
project.getPlugins().apply(ClojureBasePlugin.class);
project.getPlugins().apply(ClojureCommonPlugin.class);
ClojureExtension extension = project.getExtensions().getByType(ClojureExtension.class);
configureBuilds(project, extension);
JavaPluginConvention javaConvention = project.getConvention().getPlugin(JavaPluginConvention.class);
ClojureCommonPlugin.configureDevSource(javaConvention, sourceSet -> {
ClojureSourceSet src = (ClojureSourceSet) new DslObject(sourceSet).getConvention().getPlugins().get("clojure");
return src.getClojure();
});
}
代码示例来源:origin: gradle.plugin.com.triplequote.gradle/hydra
private static String getDefaultSourcepath(Project project, ScalaCompile scalaCompile) {
// The source sets are configured in the JavaPlugin and ScalaPlugin and they use the JavaPluginConvention to store the source sets.
SourceSetContainer sourceSets = project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets();
StringJoiner sourcepathJoiner = new StringJoiner(File.pathSeparator);
for (SourceSet set : sourceSets) {
if (set.getCompileTaskName("scala").equals(scalaCompile.getName())) {
Convention scalaConvention = (Convention) InvokerHelper.getProperty(set, "convention");
ScalaSourceSet scalaSourceSet = scalaConvention.findPlugin(ScalaSourceSet.class);
scalaSourceSet.getAllScala().getSourceDirectories().getFiles().forEach(file -> sourcepathJoiner.add(file.getAbsolutePath()));
}
}
LOGGER.debug("Hydra sourcepath: {}.", sourcepathJoiner);
return sourcepathJoiner.toString();
}
代码示例来源:origin: typelead/gradle-eta
public static void createConvention(Object conventionTarget, String conventionName, Object conventionObject) {
assertConventionObject(conventionTarget);
((HasConvention) conventionTarget).getConvention().getPlugins()
.put(conventionName, conventionObject);
}
代码示例来源:origin: diffplug/spotless
/** 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);
}
}
代码示例来源:origin: gradle-clojure/gradle-clojure
@Override
public void apply(Project project) {
project.getPlugins().apply(ClojureBasePlugin.class);
project.getPlugins().apply(ClojureCommonPlugin.class);
ClojureExtension extension = project.getExtensions().getByType(ClojureExtension.class);
configureBuilds(project, extension);
JavaPluginConvention javaConvention = project.getConvention().getPlugin(JavaPluginConvention.class);
ClojureCommonPlugin.configureDevSource(javaConvention, sourceSet -> {
ClojureSourceSet src = (ClojureSourceSet) new DslObject(sourceSet).getConvention().getPlugins().get("clojure");
return src.getClojure();
});
}
代码示例来源:origin: gradle.plugin.de.lukaskoerfer.gradle/debugging
private void setupExtendedDebug(Task task) {
ExtendedDebugConfiguration extendedDebug = new ExtendedDebugConfiguration((JavaForkOptions) task);
task.getConvention().getPlugins().put(DEBUG_SPECIFICATION_ID, extendedDebug);
}
代码示例来源:origin: diffplug/spotless
/** 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);
}
}
代码示例来源:origin: uber/okbuck
@Nullable
public String getMainClass() {
return getProject()
.getConvention()
.getPlugin(ApplicationPluginConvention.class)
.getMainClassName();
}
代码示例来源:origin: io.github.gradle-clojure/gradle-clojure-plugin
@Override
public void apply(Project project) {
project.getPlugins().apply(ClojureScriptBasePlugin.class);
project.getPlugins().apply(ClojureCommonPlugin.class);
ClojureScriptExtension extension = project.getExtensions().getByType(ClojureScriptExtension.class);
configureBuilds(project, extension);
configurePiggieback(project);
configureFigwheel(project);
JavaPluginConvention javaConvention = project.getConvention().getPlugin(JavaPluginConvention.class);
ClojureCommonPlugin.configureDevSource(javaConvention, sourceSet -> {
ClojureScriptSourceSet src = (ClojureScriptSourceSet) new DslObject(sourceSet).getConvention().getPlugins().get("clojurescript");
return src.getClojureScript();
});
}
代码示例来源:origin: MinecraftForge/ForgeGradle
private SourceSet resolveSourceSet(Object obj) {
while (obj instanceof Closure)
obj = ((Closure<?>) obj).call();
if (obj instanceof SourceSet)
return (SourceSet) obj;
else {
String name = obj.toString();
JavaPluginConvention javaConv = (JavaPluginConvention) project.getConvention().getPlugins().get("java");
return javaConv.getSourceSets().getByName(name);
}
}
代码示例来源:origin: diffplug/spotless
/** 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;
}
steps.replaceAll(step -> {
if (LicenseHeaderStep.name().equals(step.getName())) {
return step.filterByFile(LicenseHeaderStep.unsupportedJvmFilesFilter());
} else {
return step;
}
});
super.setupTask(task);
}
}
代码示例来源:origin: uber/okbuck
public JvmTarget(
Project project, String name, String aptConfigurationName, String testAptConfigurationName) {
super(project, name);
this.aptConfigurationName = aptConfigurationName;
this.testAptConfigurationName = testAptConfigurationName;
sourceSets = getProject().getConvention().getPlugin(JavaPluginConvention.class).getSourceSets();
isKotlin =
project.getPlugins().stream().anyMatch(plugin -> plugin instanceof KotlinBasePluginWrapper);
Optional<Task> compileTask =
project.getTasks().stream().filter(it -> it instanceof AbstractCompile).findFirst();
if (compileTask.isPresent()) {
fakeCompile = (AbstractCompile) compileTask.get();
} else {
fakeCompile = null;
}
}
代码示例来源:origin: gradle-clojure/gradle-clojure
@Override
public void apply(Project project) {
project.getPlugins().apply(ClojureScriptBasePlugin.class);
project.getPlugins().apply(ClojureCommonPlugin.class);
ClojureScriptExtension extension = project.getExtensions().getByType(ClojureScriptExtension.class);
configureBuilds(project, extension);
configurePiggieback(project);
configureFigwheel(project);
JavaPluginConvention javaConvention = project.getConvention().getPlugin(JavaPluginConvention.class);
ClojureCommonPlugin.configureDevSource(javaConvention, sourceSet -> {
ClojureScriptSourceSet src = (ClojureScriptSourceSet) new DslObject(sourceSet).getConvention().getPlugins().get("clojurescript");
return src.getClojureScript();
});
}
代码示例来源:origin: gradle.plugin.org.hibernate.build.gradle/hibernate-matrix-testing
public MatrixDotGradleProfile(File matrixDotGradleFile, Project project) {
super( matrixDotGradleFile.getParentFile(), project );
jdbcDependencies = prepareConfiguration( getName() );
final ConventionImpl convention = new ConventionImpl( jdbcDependencies, project );
project.getConvention().getPlugins().put( MATRIX_NODE_CONVENTION_KEY, convention );
try {
project.apply( Collections.singletonMap( "from", matrixDotGradleFile ) );
}
finally {
project.getConvention().getPlugins().remove( MATRIX_NODE_CONVENTION_KEY );
}
}
代码示例来源:origin: gradle.plugin.life.expert/archidoc
/**
* get gradle main source set
*/
private static Set< SourceSet > sourceSetMain( Project project )
{
JavaPluginConvention convention = project.getConvention().findPlugin( JavaPluginConvention.class );
Set< SourceSet > sourceSets = convention.getSourceSets().stream().filter( sourceSet -> sourceSet.getName().equals( SourceSet.MAIN_SOURCE_SET_NAME ) ).collect( Collectors.toSet() );
return sourceSets;
}
代码示例来源:origin: uber/okbuck
public String getMavenCoords() {
String group = getProject().getGroup().toString();
String id =
getProject().getConvention().getPlugin(BasePluginConvention.class).getArchivesBaseName();
String version = getProject().getVersion().toString();
return String.join(":", group, id, version);
}
代码示例来源:origin: org.gosu-lang.gosu/gradle-gosu-plugin
private void configureSourceSetDefaults(final JavaBasePlugin javaBasePlugin) {
_project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().all(sourceSet -> {
GosuSourceSet gosuSourceSet = new DefaultGosuSourceSet(sourceSet.getName(), _sourceDirectorySetFactory);
Convention sourceSetConvention = (Convention) InvokerHelper.getProperty(sourceSet, "convention");
sourceSetConvention.getPlugins().put("gosu", gosuSourceSet);
gosuSourceSet.getGosu().srcDir("src/" + sourceSet.getName() + "/gosu");
sourceSet.getResources().getFilter().exclude(element -> gosuSourceSet.getGosu().contains(element.getFile()));
sourceSet.getAllSource().source(gosuSourceSet.getGosu());
configureGosuCompile(javaBasePlugin, sourceSet, gosuSourceSet);
});
}
代码示例来源:origin: gradle.plugin.org.hibernate.build/database-profile-plugin
@SuppressWarnings("WeakerAccess")
public MatrixDotGradleProfile(File matrixDotGradleFile, Project project) {
super( matrixDotGradleFile.getParentFile(), project );
jdbcDependencies = prepareConfiguration( getName() );
final ConventionImpl convention = new ConventionImpl( jdbcDependencies, project );
project.getConvention().getPlugins().put( MATRIX_NODE_CONVENTION_KEY, convention );
try {
project.apply( Collections.singletonMap( "from", matrixDotGradleFile ) );
}
finally {
project.getConvention().getPlugins().remove( MATRIX_NODE_CONVENTION_KEY );
}
}
代码示例来源:origin: gradle.plugin.com.google.cloud.tools/jib-gradle-plugin
@Nullable
static War getWarTask(Project project) {
WarPluginConvention warPluginConvention =
project.getConvention().findPlugin(WarPluginConvention.class);
if (warPluginConvention == null) {
return null;
}
return (War) warPluginConvention.getProject().getTasks().findByName("war");
}
内容来源于网络,如有侵权,请联系作者删除!