Closed
Description
openedon Aug 23, 2016
As per the title ClasspathTrait.withFileFromClassPath
fails with
Can't get size from blah blah blah path/SKYNET-0.7-SNAPSHOT.jar!/com/example/Dockerfile
When it is given a classpath resource within a jar.
For the moment I'm working round this with a transferable that copies the resource to a byte array
static Transferable fromClasspath(final String resourcePath) {
URL resource = ClasspathTrait.class.getClassLoader()
.getResource(resourcePath);
try (InputStream stream = resource.openStream()) {
byte[] bytes = IOUtils.toByteArray(stream);
return new Transferable() {
@Override
public long getSize() {
return bytes.length;
}
@Override
public void transferTo(OutputStream outputStream) {
try {
IOUtils.write(bytes, outputStream);
} catch (IOException e) {
throw new RuntimeException(
"Can't transfer resource " + resourcePath, e);
}
}
};
} catch (IOException e) {
throw new RuntimeException(e);
}
};
But it would be preferable for the DSL to support this.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Metadata
Assignees
Labels
No labels