/** * Register an API Gateway API that should have its DefinitionBody property updated in the * Cloudformation template * * @param ref the Cloudformation Ref of the API to update * @param swagger the file containing the swagger definition of the API */ public void api(String ref, FileCollection swagger) { getInputs().files(swagger); apis.put(ref, swagger.getSingleFile()); }
/** * Register a lambda function that should have its CodeUri property updated in the Cloudformation * template * * @param ref the CloudFormation Ref of the function to update * @param zip the files containing the function's deployment package */ public void lambdaFunction(String ref, FileCollection zip) { getInputs().files(zip); lambdaFunctions.put(ref, zip.getSingleFile()); }
private File getJar() { if (agentJar == null) { agentJar = agentConfig .filter( (file) -> file.getName().startsWith("scott")) .getSingleFile(); } return agentJar; } }
private File getJar() { if (agentJar == null) { agentJar = agentConfig .filter( (file) -> file.getName().startsWith("scott")) .getSingleFile(); } return agentJar; } }
@Override public FileCollection createDelegate() { File archiveFile = fileCollection.getSingleFile(); String fileExtension = Files.getFileExtension(archiveFile.getName()); FileTree archiveContents = fileExtension.equals("jar") || fileExtension.equals("zip") ? fileOperations.zipTree(archiveFile) : fileOperations.tarTree(archiveFile); PatternSet patternSet = new PatternSet(); patternSet.include(path); return archiveContents.matching(patternSet); }
private void copyFreezeConfigIfChanged(File workingDir) { if (isFreezeConfigChanged()) { /* Copy the project-global freeze file into the working directory. */ File tmpFreezeConfig = null; try { tmpFreezeConfig = freezeConfigFile .filter(file -> file.getName().endsWith(".freeze")).getSingleFile(); } catch (IllegalStateException e) { throw new GradleException ("The freezeConfig file collection contains more than one element!", e); } final File freezeConfig = tmpFreezeConfig; project.copy(copySpec -> { copySpec.from(freezeConfig); copySpec.into(workingDir); }); } } }
public File asFile(String targetCharset) { try { Charset targetCharsetObj = Charset.forName(targetCharset); if (targetCharsetObj.equals(charset)) { return fileCollection.getSingleFile(); } File targetFile = tempFileProvider.createTemporaryFile("fileCollection", ".txt", "resource"); try { Files.asCharSource(fileCollection.getSingleFile(), charset).copyTo(Files.asCharSink(targetFile, targetCharsetObj)); } catch (IOException e) { throw new ResourceException("Could not write " + getDisplayName() + " content to " + targetFile + ".", e); } return targetFile; } catch (Exception e) { throw ResourceExceptions.readFailed(getDisplayName(), e); } }
/** * Returns the appengine service directory for this project and modifies the task dependencies of * run/start to ensure {@code serviceProject} is built first. */ public File projectAsService(Project serviceProject) { if (!serviceProject.equals(project)) { project.evaluationDependsOn(serviceProject.getPath()); } project .getTasks() .findByName(AppEngineStandardPlugin.RUN_TASK_NAME) .dependsOn(serviceProject.getTasks().findByPath(BasePlugin.ASSEMBLE_TASK_NAME)); project .getTasks() .findByName(AppEngineStandardPlugin.START_TASK_NAME) .dependsOn(serviceProject.getTasks().findByPath(BasePlugin.ASSEMBLE_TASK_NAME)); return serviceProject .getTasks() .findByName(AppEngineStandardPlugin.EXPLODE_WAR_TASK_NAME) .getOutputs() .getFiles() .getSingleFile(); }
@NonNull public File getJavaResourcesForUnitTesting() { if (processJavaResourcesTask != null) { return processJavaResourcesTask.getOutputs().getFiles().getSingleFile(); } else { return getScope().getSourceFoldersJavaResDestinationDir(); } } }
private S3UploadTask createUploadZipTask(final Zip zipTask) { final S3UploadTask task = createTask("uploadZip", S3UploadTask.class); task.setDescription("Upload lambda zip to s3"); task.setGroup(TASK_GROUP); task.dependsOn(zipTask); task.config = config; task.file = zipTask.getOutputs().getFiles().getSingleFile(); return task; }
public void fetchContributors(FetchGitHubContributorsTask task) { LOG.lifecycle(" Fetching all GitHub contributors of {}", task.getRepository()); ContributorsProvider contributorsProvider = Contributors.getGitHubContributorsProvider( task.getApiUrl(), task.getRepository(), task.getReadOnlyAuthToken(), task.getIgnoredContributors()); ProjectContributorsSet contributors = contributorsProvider.getAllContributorsForProject(); ProjectContributorsSerializer serializer = new ProjectContributorsSerializer(); final String json = serializer.serialize(contributors); IOUtil.writeFile(task.getOutputs().getFiles().getSingleFile(), json); LOG.lifecycle(" Serialized contributors information: {}", task.getProject().relativePath(task.getOutputs().getFiles().getSingleFile())); } }
public void fetchContributors(FetchGitHubContributorsTask task) { LOG.lifecycle(" Fetching all GitHub contributors of {}", task.getRepository()); ContributorsProvider contributorsProvider = Contributors.getGitHubContributorsProvider( task.getApiUrl(), task.getRepository(), task.getReadOnlyAuthToken(), task.getIgnoredContributors()); ProjectContributorsSet contributors = contributorsProvider.getAllContributorsForProject(); ProjectContributorsSerializer serializer = new ProjectContributorsSerializer(); final String json = serializer.serialize(contributors); IOUtil.writeFile(task.getOutputs().getFiles().getSingleFile(), json); LOG.lifecycle(" Serialized contributors information: {}", task.getProject().relativePath(task.getOutputs().getFiles().getSingleFile())); } }
task.setOutputName(extension.getOutputName()); task.setGraalVersion(extension.getGraalVersion()); task.setJarFile(jar.map(j -> j.getOutputs().getFiles().getSingleFile())); task.setClasspath(project.getConfigurations().named("runtimeClasspath")); task.setCacheDir(cacheDir);
task.setOutputName(extension.getOutputName()); task.setGraalVersion(extension.getGraalVersion()); task.setJarFile(jar.map(j -> j.getOutputs().getFiles().getSingleFile())); task.setClasspath(project.getConfigurations().named("runtimeClasspath")); task.setCacheDir(cacheDir);
/** * Test if the output is generated correctly for a single source and a * destination folder * @throws Exception if anything went wrong */ @Test public void singleOutputFileWithDestinationDirectory() throws Exception { Download t = makeProjectAndTask(); t.src(makeSrc(TEST_FILE_NAME)); t.dest(folder.getRoot()); assertEquals(new File(folder.getRoot(), TEST_FILE_NAME), t.getOutputs().getFiles().getSingleFile()); }
/** * Test if the output is generated correctly for a single source and a * destination file * @throws Exception if anything went wrong */ @Test public void singleOutputFileWithDestinationFile() throws Exception { Download t = makeProjectAndTask(); t.src(makeSrc(TEST_FILE_NAME)); File dst = folder.newFile(); t.dest(dst); assertEquals(dst, t.getOutputs().getFiles().getSingleFile()); }
private static void configureDetailedNotes(final UpdateReleaseNotesTask task, final FetchReleaseNotesTask releaseNotesFetcher, final Project project, final ShipkitConfiguration conf, final Task contributorsFetcher) { task.dependsOn(releaseNotesFetcher); task.dependsOn(contributorsFetcher); task.setVersion(project.getVersion().toString()); task.setTagPrefix(conf.getGit().getTagPrefix()); task.setGitHubRepository(conf.getGitHub().getRepository()); task.setDevelopers(conf.getTeam().getDevelopers()); task.setContributors(conf.getTeam().getContributors()); if (conf.getTeam().getContributors().isEmpty()) { task.setContributorsDataFile(contributorsFetcher.getOutputs().getFiles().getSingleFile()); } task.setGitHubLabelMapping(conf.getReleaseNotes().getLabelMapping()); task.setReleaseNotesFile(project.file(conf.getReleaseNotes().getFile())); task.setGitHubUrl(conf.getGitHub().getUrl()); task.setPreviousVersion(project.getExtensions().getByType(VersionInfo.class).getPreviousVersion()); task.setReleaseNotesData(releaseNotesFetcher.getOutputFile()); } }
private static void configureDetailedNotes(final UpdateReleaseNotesTask task, final FetchReleaseNotesTask releaseNotesFetcher, final Project project, final ShipkitConfiguration conf, final Task contributorsFetcher) { task.dependsOn(releaseNotesFetcher); task.dependsOn(contributorsFetcher); task.setVersion(project.getVersion().toString()); task.setTagPrefix(conf.getGit().getTagPrefix()); task.setGitHubRepository(conf.getGitHub().getRepository()); task.setDevelopers(conf.getTeam().getDevelopers()); task.setContributors(conf.getTeam().getContributors()); if (conf.getTeam().getContributors().isEmpty()) { task.setContributorsDataFile(contributorsFetcher.getOutputs().getFiles().getSingleFile()); } task.setGitHubLabelMapping(conf.getReleaseNotes().getLabelMapping()); task.setReleaseNotesFile(project.file(conf.getReleaseNotes().getFile())); task.setGitHubUrl(conf.getGitHub().getUrl()); task.setPreviousVersion(project.getExtensions().getByType(VersionInfo.class).getPreviousVersion()); task.setReleaseNotesData(releaseNotesFetcher.getOutputFile()); } }