@Override public Abstract.ClassDefinition loadSource(SourceId sourceId, ErrorReporter errorReporter) throws IOException { if (sourceId.getStorage() != this) return null; if (!isAvailable(sourceId)) return null; Path file = sourceFileForSource(sourceId); FileSource fileSource = new FileSource(sourceId, file); Abstract.ClassDefinition definition = fileSource.load(errorReporter); // Make sure we loaded the right revision return Files.getLastModifiedTime(file).equals(sourceId.myMtime) ? definition : null; }
protected DataFileSource getDataFileSourceIfExists(String name) throws IOException { DataFileSource src = m_fileSrc.getFileSourceOnlyIfExists(name); if (src != null) { s_log.debug("Creating data file source for [{}]", src.getDescription()); } return src; }
public File createTemporaryFile(String prefix, @Nullable String suffix, String... path) { File dir = new File(baseDir.get(), GUtil.join(path, "/")); GFileUtils.createDirectory(dir); try { return File.createTempFile(prefix, suffix, dir); } catch (IOException e) { throw new UncheckedIOException(e.getMessage(), e); } }
protected List<String> getAllMetadataFileNames() throws IOException { List<String> names = new ArrayList<String>(); for (String name : Arrays.asList(m_serFileName, m_confFileName)) { if (m_fileSrc.fileExists(name)) { names.add(name); } } return names; }
@Test public void createsPackageWithWarFromFilenameAndDefaultVersion() throws IOException { WarImporter importer = new WarImporter("(.+)", "1.0", false, null); FileSource source = new FileSource(WAR_WITH_MANIFEST); PackageInfo packageInfo = importer.preparePackage(source, DUMMY_IMPORT_CTX); // from the filename assertEquals("war-with-manifest.war", packageInfo.getApplicationName()); assertEquals("1.0", packageInfo.getApplicationVersion()); List<Deployable> deployables = importer.importEntities(packageInfo, DUMMY_IMPORT_CTX).getDeployables(); assertEquals(1, deployables.size()); assertTrue(format("Expected instance of %s", War.class), deployables.get(0) instanceof War); War War = (War) deployables.get(0); assertTrue( "Expected the files to contain the same bytes", Files.equal(source.getFile(), ((LocalFile) War.getFile()).getFile())); assertEquals("Applications/war-with-manifest.war/1.0/war-with-manifest.war", War.getId()); assertEquals("war-with-manifest.war", War.getName()); }
public File createTemporaryDirectory( @Nullable String prefix, @Nullable String suffix, @Nullable String... path) { File dir = new File(baseDir.get(), GUtil.join(path, "/")); GFileUtils.createDirectory(dir); try { // TODO: This is not a great paradigm for creating a temporary directory. // See // http://guava-libraries.googlecode.com/svn/tags/release08/javadoc/com/google/common/io/Files.html#createTempDir%28%29 for an alternative. File tmpDir = File.createTempFile("gradle", "projectDir", dir); tmpDir.delete(); tmpDir.mkdir(); return tmpDir; } catch (IOException e) { throw new UncheckedIOException(e.getMessage(), e); } }
public File newTemporaryFile(String... path) { return GFileUtils.canonicalise(new File(baseDir.get(), GUtil.join(path, "/"))); }
protected DataFileSource getDataFileSource(String name) throws IOException { DataFileSource src = m_fileSrc.getFileSource(name); s_log.debug("Creating data file source for [{}]", src.getDescription()); return src; }
protected List<String> getAllDataFileNames() throws IOException { List<String> names = new ArrayList<String>(m_fileSrc.getAllFileNames()); names.remove(m_serFileName); names.remove(m_confFileName); return names; }
public String getDescription() { return String.format("directory dataset source stored by [%s]", m_fileSrc.getDescription()); }
public void ensureExists() throws IOException { m_fileSrc.ensureExists(); }
protected DataFileSink getDataFileSink(String name) throws IOException { DataFileSink sink = m_fileSrc.getFileSink(name); s_log.debug("Creating data file sink for [{}]", sink.getDescription()); return sink; }