/** * Locates the jar file that contains the given class. * <p> * <p> * Note that jar files are not always loaded from {@link File}, * so for diagnostics purposes {@link #jarURL(Class)} is preferrable. * * @throws IllegalArgumentException * if failed to determine. */ public static File jarFile(Class<?> clazz) throws IOException { return jarFile(classFileUrl(clazz), clazz.getName().replace('.', '/') + ".class"); }
/** * Locates the jar file that contains the given class. * <p> * <p> * Note that jar files are not always loaded from {@link File}, * so for diagnostics purposes {@link #jarURL(Class)} is preferrable. * * @throws IllegalArgumentException * if failed to determine. */ public static File jarFile(Class<?> clazz) throws IOException { return jarFile(classFileUrl(clazz), clazz.getName().replace('.', '/') + ".class"); }
private static void copyDockerfileDirectoryFromClasspath(Class<?> containerObject, String dockerfileLocation, File dir) throws IOException { File jar = null; try { jar = Which.jarFile(containerObject); } catch (IllegalArgumentException | IOException e) { throw new IllegalArgumentException(e); } if (jar != null && jar.isFile()) { // files are packaged into a jar/war. extract them dockerfileLocation += "/"; copyDockerfileDirectoryFromPackaged(jar, dockerfileLocation, dir); } else { // Dockerfile is not packaged into a jar file, so copy locally copyDockerfileDirectoryFromLocal(dockerfileLocation, dir); } }
private static void copyDockerfileDirectoryFromClasspath(Class<?> containerObject, String dockerfileLocation, File dir) throws IOException { File jar = null; try { jar = Which.jarFile(containerObject); } catch (IllegalArgumentException | IOException e) { throw new IllegalArgumentException(e); } if (jar != null && jar.isFile()) { // files are packaged into a jar/war. extract them dockerfileLocation += "/"; copyDockerfileDirectoryFromPackaged(jar, dockerfileLocation, dir); } else { // Dockerfile is not packaged into a jar file, so copy locally copyDockerfileDirectoryFromLocal(dockerfileLocation, dir); } }