public JavaPluginConvention getJavaConvention(final Project project) { return project.getConvention().getPlugin(JavaPluginConvention.class); }
@Nullable public String getMainClass() { return getProject() .getConvention() .getPlugin(ApplicationPluginConvention.class) .getMainClassName(); }
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; } }
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); }
public String getTargetCompatibility() { return javaVersion( getProject() .getConvention() .getPlugin(JavaPluginConvention.class) .getTargetCompatibility()); }
public String getSourceCompatibility() { return javaVersion( getProject() .getConvention() .getPlugin(JavaPluginConvention.class) .getSourceCompatibility()); }
/** 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); } }
/** 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); } }
/** 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); } }
protected void setupTask(SpotlessTask task) { if (target == null) { JavaPluginConvention convention = getProject().getConvention().getPlugin(JavaPluginConvention.class); if (convention == null || !getProject().getPlugins().hasPlugin(GroovyBasePlugin.class)) { throw new GradleException("You must apply the groovy plugin before the spotless plugin if you are using the groovy extension.");
private JavaPluginConvention getJavaPluginConvention(final Project project) { final JavaPluginConvention javaPlugin = project.getConvention().getPlugin(JavaPluginConvention.class); if (javaPlugin == null) { throw new GradleException("You must apply the java plugin before the classycle plugin."); } return javaPlugin; }
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); } }
private void configureAppPlugin() { final ApplicationPluginConvention convention = this.project.getConvention().findPlugin( ApplicationPluginConvention.class ); convention.setMainClassName( "io.purplejs.boot.MainApp" ); final JavaExec runTask = (JavaExec) this.project.getTasks().getByName( ApplicationPlugin.TASK_RUN_NAME ); runTask.systemProperty( "io.purplejs.runMode", "dev" ); final String devDirs = new File( this.project.getProjectDir(), "src/main/resources" ).getAbsolutePath(); runTask.systemProperty( "io.purplejs.devSourceDirs", devDirs ); } }
/** * Get the library directory * * @return Library directory */ public File getLibsDir() { BasePluginConvention baseConvention = this.project.getConvention().getPlugin(BasePluginConvention.class); File libsDir = Validate.notNull(baseConvention.getLibsDir(), "The libs dir must not be null"); return libsDir; }
public static SourceSet getMainSourceSet(Project project) { final JavaPluginConvention java = project.getConvention().getPlugin(JavaPluginConvention.class); return java.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME); } }
/** * Provide the Java plugin convention * * @param project Project to get convention from * @return Java plugin convention */ @Model @Hidden public JavaPluginConvention javaPluginConvention(Project project) { return project.getConvention().getPlugin(JavaPluginConvention.class); }
/** * Get the library directory * * @return Library directory */ public File getLibsDir() { BasePluginConvention baseConvention = this.project.getConvention().getPlugin(BasePluginConvention.class); File libsDir = Validate.notNull(baseConvention.getLibsDir(), "The libs dir must not be null"); return libsDir; }
private FileCollection getOutputClassDir(Project project) { return project.getConvention() .getPlugin(JavaPluginConvention.class) .getSourceSets() .getByName("main") .getOutput() .getClassesDirs(); }
private void configureLibPropertiesTask(PropertiesTask thin, Project project) { thin.setConfiguration(findRuntimeClasspath(project)); SourceSetContainer sourceSets = project.getConvention() .getPlugin(JavaPluginConvention.class).getSourceSets(); File resourcesDir = sourceSets.getByName("main").getOutput().getResourcesDir(); thin.setOutput(new File(resourcesDir, "META-INF")); }
private void configureGosuDoc( final Project project ) { GosuDoc gosuDoc = project.getTasks().create(GOSUDOC_TASK_NAME, GosuDoc.class); gosuDoc.setDescription("Generates Gosudoc API documentation for the main source code."); gosuDoc.setGroup(JavaBasePlugin.DOCUMENTATION_GROUP); JavaPluginConvention convention = project.getConvention().getPlugin(JavaPluginConvention.class); SourceSet sourceSet = convention.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME); gosuDoc.setClasspath(sourceSet.getOutput().plus(sourceSet.getCompileClasspath())); Convention sourceSetConvention = (Convention) InvokerHelper.getProperty(sourceSet, "convention"); GosuSourceSet gosuSourceSet = sourceSetConvention.getPlugin(GosuSourceSet.class); gosuDoc.setSource((Object) gosuSourceSet.getGosu()); // Gradle 4.0 overloads setSource; must upcast to Object for backwards compatibility }