public File call() { try { return getMainOutput(project).getResourcesDir(); } catch (Exception e) { return null; } } });
public File call() { try { return getMainOutput(project).getResourcesDir(); } catch (Exception e) { return null; } } });
@Override public File call() throws Exception { return new File( sourceSetOutput.getResourcesDir(), "META-INF/config.json"); }
@Override public File call() throws Exception { return new File( sourceSetOutput.getResourcesDir(), "META-INF/resources"); }
private List<File> getClassesDirs(SourceSetOutput sourceSet) { // gradle 4.0 api //return sourceSet.getClassesDirs().getFiles(); List<File> files = new ArrayList<File>(sourceSet.getFiles()); files.remove(sourceSet.getResourcesDir()); return files; }
private List<File> getClassesDirs(SourceSetOutput sourceSet) { // gradle 4.0 api //return sourceSet.getClassesDirs().getFiles(); List<File> files = new ArrayList<File>(sourceSet.getFiles()); files.remove(sourceSet.getResourcesDir()); return files; }
@Override public File call() throws Exception { SourceSetOutput sourceSetOutput = sourceSet.getOutput(); return new File( sourceSetOutput.getResourcesDir(), "META-INF/resources"); }
public Object call() throws Exception { if (project.hasProperty("rebel.rebelXmlDirectory")) { return new File(project.property("rebel.rebelXmlDirectory").toString()); } else if (rebelExtension.getRebelXmlDirectory() != null) { return new File(rebelExtension.getRebelXmlDirectory()); } else { return getMainOutput(project).getResourcesDir(); } } });
public Object call() throws Exception { if (project.hasProperty("rebel.rebelXmlDirectory")) { return new File(project.property("rebel.rebelXmlDirectory").toString()); } else if (rebelExtension.getRebelXmlDirectory() != null) { return new File(rebelExtension.getRebelXmlDirectory()); } else { return getMainOutput(project).getResourcesDir(); } } });
private static Path outputManifest(Jar jarTask) { JavaPluginConvention javaConvention = jarTask.getProject().getConvention().getPlugin(JavaPluginConvention.class); SourceSet main = javaConvention.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME); return main.getOutput().getResourcesDir().toPath().resolve("META-INF/MANIFEST.MF"); }
private void addClassesAndResourcesDirs(Set<URL> extraURLs) throws IllegalAccessException, InvocationTargetException, MalformedURLException { JavaPluginConvention plugin = getProject().getConvention().getPlugin(JavaPluginConvention.class); for (SourceSet sourceSet : plugin.getSourceSets()) { try { @SuppressWarnings("JavaReflectionMemberAccess") Method getClassesDirs = SourceSetOutput.class.getMethod("getClassesDirs"); // use alternative method available in Gradle 4.0 FileCollection classesDirs = (FileCollection) getClassesDirs.invoke(sourceSet.getOutput()); for (File directory : classesDirs.getFiles()) { URL classesUrl = directory.toURI().toURL(); getLogger().debug("Adding directory to Classpath: " + classesUrl); extraURLs.add(classesUrl); } } catch (NoSuchMethodException e) { // use original method available in Gradle 3.x 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); } }
private void copyResource(String name, boolean optional) { SourceSet sourceSet = getMainSourceSet(); SourceDirectorySet resources = sourceSet.getResources(); File outputDir = sourceSet.getOutput().getResourcesDir(); File outputResourceFile = new File(outputDir, name); File inputResourceFile = getInputResource(resources, name); if (optional && inputResourceFile == null) { throw new IllegalStateException("no " + name + " found in " + resources.getSrcDirs()); } else if (inputResourceFile != null && hasChanged(inputResourceFile, outputResourceFile)) { outputResourceFile.getParentFile().mkdirs(); Project project = getProject(); project.copy(copySpec -> { copySpec.from(inputResourceFile); copySpec.into(outputResourceFile.getParentFile()); }); } }
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")); }
public ServiceLoaderTask() throws IOException { super.setDescription("Generate META-INF/services manifests for use with ServiceLoaders"); super.setGroup("Source Generation"); javaConvention = project.getConvention().getPlugin(JavaPluginConvention.class); this.main = javaConvention.getSourceSets().findByName(SourceSet.MAIN_SOURCE_SET_NAME); SourceSetOutput mainOutput = main.getOutput(); classesOutput = mainOutput.getClassesDirs(); outputDirectory = new File(mainOutput.getResourcesDir(), "META-INF/services"); }
@Override public FileCollection call() throws Exception { final SourceSet mainSourceSet = getMainSourceSet(); return project.files(mainSourceSet.getAllJava().getSrcDirs()).plus(project.files(mainSourceSet.getOutput().getResourcesDir())); }});
private void addSourceSet(ConfigurableFileCollection sources, Project project, String sourceSet) { JavaPluginConvention javaConvention = project.getConvention().findPlugin(JavaPluginConvention.class); if (javaConvention != null) { SourceSet mainSourceSet = javaConvention.getSourceSets().getByName(sourceSet); sources .from(project.files(mainSourceSet.getOutput().getResourcesDir())) .from(project.files(mainSourceSet.getOutput().getClassesDirs())) .from(project.files(mainSourceSet.getAllSource().getSrcDirs())); } }
private void addSourceSet(FileCollection sources, Project project, String sourceSet) { JavaPluginConvention javaConvention = project.getConvention().getPlugin(JavaPluginConvention.class); SourceSet mainSourceSet = javaConvention.getSourceSets().getByName(sourceSet); sources.add(project.files(mainSourceSet.getOutput().getResourcesDir())) .plus(project.files(mainSourceSet.getOutput().getClassesDirs())) .plus(project.files(mainSourceSet.getAllSource().getSrcDirs())); }
return sourceSet.getCompileClasspath() .plus(project.files(sourceSet.getJava().getOutputDir())) .plus(project.files(sourceSet.getOutput().getResourcesDir())); });
public void configure(final Project project, final PutnamiExtension extention) { final CompilerOption options = extention.getCompile(); options.init(getProject()); JavaPluginConvention javaConvention = project.getConvention().getPlugin(JavaPluginConvention.class); SourceSet mainSourceSet = javaConvention.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME); final FileCollection sources = getProject() .files(project.files(mainSourceSet.getOutput().getResourcesDir())) .plus(project.files(mainSourceSet.getOutput().getClassesDirs())) .plus(getProject().files(mainSourceSet.getAllSource().getSrcDirs())); ConventionMapping mapping = ((IConventionAware) this).getConventionMapping(); mapping.map("modules", new Callable<List<String>>() { @Override public List<String> call() { return extention.getModule(); } }); mapping.map("war", new Callable<File>() { @Override public File call() { return new File(getProject().getBuildDir(), "out"); } }); mapping.map("src", new Callable<FileCollection>() { @Override public FileCollection call() { return sources; } }); }
public void configure(final Project project, final GwtExtension extention) { final CompilerOption options = extention.getCompile(); options.init(getProject()); JavaPluginConvention javaConvention = project.getConvention().getPlugin(JavaPluginConvention.class); SourceSet mainSourceSet = javaConvention.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME); final FileCollection sources = getProject() .files(project.files(mainSourceSet.getOutput().getResourcesDir())) .plus(project.files(mainSourceSet.getOutput().getClassesDirs())) .plus(getProject().files(mainSourceSet.getAllSource().getSrcDirs())); ConventionMapping mapping = ((IConventionAware) this).getConventionMapping(); mapping.map("modules", new Callable<List<String>>() { @Override public List<String> call() { return extention.getModule(); } }); mapping.map("war", new Callable<File>() { @Override public File call() { return new File(getProject().getBuildDir(), "out"); } }); mapping.map("src", new Callable<FileCollection>() { @Override public FileCollection call() { return sources; } }); }