public JavaPluginConvention getJavaConvention(final Project project) { return project.getConvention().getPlugin(JavaPluginConvention.class); }
@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(); }); }
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(); }
public static void createConvention(Object conventionTarget, String conventionName, Object conventionObject) { assertConventionObject(conventionTarget); ((HasConvention) conventionTarget).getConvention().getPlugins() .put(conventionName, conventionObject); }
/** 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); } }
@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(); }); }
private void setupExtendedDebug(Task task) { ExtendedDebugConfiguration extendedDebug = new ExtendedDebugConfiguration((JavaForkOptions) task); task.getConvention().getPlugins().put(DEBUG_SPECIFICATION_ID, extendedDebug); }
/** 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); } }
@Nullable public String getMainClass() { return getProject() .getConvention() .getPlugin(ApplicationPluginConvention.class) .getMainClassName(); }
@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(); }); }
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); } }
/** 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); } }
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; } }
@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(); }); }
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 ); } }
/** * 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; }
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); }
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); }); }
@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 ); } }
@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"); }