Java 类org.springframework.boot.loader.tools.JarWriter 实例源码

项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ArchiveCommand.java   
private void writeJar(File file, Class<?>[] compiledClasses,
        List<MatchedResource> classpathEntries, List<URL> dependencies)
                throws FileNotFoundException, IOException, URISyntaxException {
    final List<Library> libraries;
    JarWriter writer = new JarWriter(file);
    try {
        addManifest(writer, compiledClasses);
        addCliClasses(writer);
        for (Class<?> compiledClass : compiledClasses) {
            addClass(writer, compiledClass);
        }
        libraries = addClasspathEntries(writer, classpathEntries);
    }
    finally {
        writer.close();
    }
    libraries.addAll(createLibraries(dependencies));
    Repackager repackager = new Repackager(file);
    repackager.setMainClass(PackagedSpringApplicationLauncher.class.getName());
    repackager.repackage(new Libraries() {

        @Override
        public void doWithLibraries(LibraryCallback callback) throws IOException {
            for (Library library : libraries) {
                callback.library(library);
            }
        }
    });
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ArchiveCommand.java   
private void addManifest(JarWriter writer, Class<?>[] compiledClasses)
        throws IOException {
    Manifest manifest = new Manifest();
    manifest.getMainAttributes().putValue("Manifest-Version", "1.0");
    manifest.getMainAttributes().putValue(
            PackagedSpringApplicationLauncher.SOURCE_ENTRY,
            commaDelimitedClassNames(compiledClasses));
    writer.writeManifest(manifest);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ArchiveCommand.java   
protected void addCliClasses(JarWriter writer) throws IOException {
    addClass(writer, PackagedSpringApplicationLauncher.class);
    addClass(writer, SpringApplicationLauncher.class);
    Resource[] resources = new PathMatchingResourcePatternResolver()
            .getResources("org/springframework/boot/groovy/**");
    for (Resource resource : resources) {
        String url = resource.getURL().toString();
        addResource(writer, resource,
                url.substring(url.indexOf("org/springframework/boot/groovy/")));
    }
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ArchiveCommand.java   
protected final void addClass(JarWriter writer, ClassLoader classLoader,
        String sourceClass) throws IOException {
    if (classLoader == null) {
        classLoader = Thread.currentThread().getContextClassLoader();
    }
    String name = sourceClass.replace(".", "/") + ".class";
    InputStream stream = classLoader.getResourceAsStream(name);
    writer.writeEntry(this.layout.getClassesLocation() + name, stream);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ArchiveCommand.java   
private List<Library> addClasspathEntries(JarWriter writer,
        List<MatchedResource> entries) throws IOException {
    List<Library> libraries = new ArrayList<Library>();
    for (MatchedResource entry : entries) {
        if (entry.isRoot()) {
            libraries.add(new Library(entry.getFile(), LibraryScope.COMPILE));
        }
        else {
            writer.writeEntry(entry.getName(),
                    new FileInputStream(entry.getFile()));
        }
    }
    return libraries;
}
项目:spring-boot-concourse    文件:ArchiveCommand.java   
private void writeJar(File file, Class<?>[] compiledClasses,
        List<MatchedResource> classpathEntries, List<URL> dependencies)
                throws FileNotFoundException, IOException, URISyntaxException {
    final List<Library> libraries;
    JarWriter writer = new JarWriter(file);
    try {
        addManifest(writer, compiledClasses);
        addCliClasses(writer);
        for (Class<?> compiledClass : compiledClasses) {
            addClass(writer, compiledClass);
        }
        libraries = addClasspathEntries(writer, classpathEntries);
    }
    finally {
        writer.close();
    }
    libraries.addAll(createLibraries(dependencies));
    Repackager repackager = new Repackager(file);
    repackager.setMainClass(PackagedSpringApplicationLauncher.class.getName());
    repackager.repackage(new Libraries() {

        @Override
        public void doWithLibraries(LibraryCallback callback) throws IOException {
            for (Library library : libraries) {
                callback.library(library);
            }
        }
    });
}
项目:spring-boot-concourse    文件:ArchiveCommand.java   
private void addManifest(JarWriter writer, Class<?>[] compiledClasses)
        throws IOException {
    Manifest manifest = new Manifest();
    manifest.getMainAttributes().putValue("Manifest-Version", "1.0");
    manifest.getMainAttributes().putValue(
            PackagedSpringApplicationLauncher.SOURCE_ENTRY,
            commaDelimitedClassNames(compiledClasses));
    writer.writeManifest(manifest);
}
项目:spring-boot-concourse    文件:ArchiveCommand.java   
protected void addCliClasses(JarWriter writer) throws IOException {
    addClass(writer, PackagedSpringApplicationLauncher.class);
    addClass(writer, SpringApplicationLauncher.class);
    Resource[] resources = new PathMatchingResourcePatternResolver()
            .getResources("org/springframework/boot/groovy/**");
    for (Resource resource : resources) {
        String url = resource.getURL().toString();
        addResource(writer, resource,
                url.substring(url.indexOf("org/springframework/boot/groovy/")));
    }
}
项目:spring-boot-concourse    文件:ArchiveCommand.java   
protected final void addClass(JarWriter writer, ClassLoader classLoader,
        String sourceClass) throws IOException {
    if (classLoader == null) {
        classLoader = Thread.currentThread().getContextClassLoader();
    }
    String name = sourceClass.replace(".", "/") + ".class";
    InputStream stream = classLoader.getResourceAsStream(name);
    writer.writeEntry(this.layout.getClassesLocation() + name, stream);
}
项目:spring-boot-concourse    文件:ArchiveCommand.java   
private List<Library> addClasspathEntries(JarWriter writer,
        List<MatchedResource> entries) throws IOException {
    List<Library> libraries = new ArrayList<Library>();
    for (MatchedResource entry : entries) {
        if (entry.isRoot()) {
            libraries.add(new Library(entry.getFile(), LibraryScope.COMPILE));
        }
        else {
            writer.writeEntry(entry.getName(),
                    new FileInputStream(entry.getFile()));
        }
    }
    return libraries;
}
项目:contestparser    文件:ArchiveCommand.java   
private void writeJar(File file, Class<?>[] compiledClasses,
        List<MatchedResource> classpathEntries, List<URL> dependencies)
                throws FileNotFoundException, IOException, URISyntaxException {
    final List<Library> libraries;
    JarWriter writer = new JarWriter(file);
    try {
        addManifest(writer, compiledClasses);
        addCliClasses(writer);
        for (Class<?> compiledClass : compiledClasses) {
            addClass(writer, compiledClass);
        }
        libraries = addClasspathEntries(writer, classpathEntries);
    }
    finally {
        writer.close();
    }
    libraries.addAll(createLibraries(dependencies));
    Repackager repackager = new Repackager(file);
    repackager.setMainClass(PackagedSpringApplicationLauncher.class.getName());
    repackager.repackage(new Libraries() {

        @Override
        public void doWithLibraries(LibraryCallback callback) throws IOException {
            for (Library library : libraries) {
                callback.library(library);
            }
        }
    });
}
项目:contestparser    文件:ArchiveCommand.java   
private void addManifest(JarWriter writer, Class<?>[] compiledClasses)
        throws IOException {
    Manifest manifest = new Manifest();
    manifest.getMainAttributes().putValue("Manifest-Version", "1.0");
    manifest.getMainAttributes().putValue(
            PackagedSpringApplicationLauncher.SOURCE_ENTRY,
            commaDelimitedClassNames(compiledClasses));
    writer.writeManifest(manifest);
}
项目:contestparser    文件:ArchiveCommand.java   
protected void addCliClasses(JarWriter writer) throws IOException {
    addClass(writer, PackagedSpringApplicationLauncher.class);
    addClass(writer, SpringApplicationLauncher.class);
    Resource[] resources = new PathMatchingResourcePatternResolver()
            .getResources("org/springframework/boot/groovy/**");
    for (Resource resource : resources) {
        String url = resource.getURL().toString();
        addResource(writer, resource,
                url.substring(url.indexOf("org/springframework/boot/groovy/")));
    }
}
项目:contestparser    文件:ArchiveCommand.java   
protected final void addClass(JarWriter writer, ClassLoader classLoader,
        String sourceClass) throws IOException {
    if (classLoader == null) {
        classLoader = Thread.currentThread().getContextClassLoader();
    }
    String name = sourceClass.replace(".", "/") + ".class";
    InputStream stream = classLoader.getResourceAsStream(name);
    writer.writeEntry(this.layout.getClassesLocation() + name, stream);
}
项目:contestparser    文件:ArchiveCommand.java   
private List<Library> addClasspathEntries(JarWriter writer,
        List<MatchedResource> entries) throws IOException {
    List<Library> libraries = new ArrayList<Library>();
    for (MatchedResource entry : entries) {
        if (entry.isRoot()) {
            libraries.add(new Library(entry.getFile(), LibraryScope.COMPILE));
        }
        else {
            writer.writeEntry(entry.getName(),
                    new FileInputStream(entry.getFile()));
        }
    }
    return libraries;
}
项目:midpoint    文件:MidPointWarLayout.java   
@Override
public void writeLoadedClasses(LoaderClassesWriter writer) throws IOException {
    JarWriter jarWriter = (JarWriter) writer;
    writer.writeLoaderClasses();

    JarFile self = createSelf();
    jarWriter.writeEntries(self);
}
项目:midpoint    文件:MidPointWarLayout.java   
@Override
public void writeLoadedClasses(LoaderClassesWriter writer) throws IOException {
    JarWriter jarWriter = (JarWriter) writer;
    writer.writeLoaderClasses();

    JarFile self = createSelf();
    jarWriter.writeEntries(self);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:WarCommand.java   
@Override
protected void addCliClasses(JarWriter writer) throws IOException {
    addClass(writer, null, "org.springframework.boot."
            + "cli.app.SpringApplicationWebApplicationInitializer");
    super.addCliClasses(writer);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ArchiveCommand.java   
protected final void addClass(JarWriter writer, Class<?> sourceClass)
        throws IOException {
    addClass(writer, sourceClass.getClassLoader(), sourceClass.getName());
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ArchiveCommand.java   
private void addResource(JarWriter writer, Resource resource, String name)
        throws IOException {
    InputStream stream = resource.getInputStream();
    writer.writeEntry(name, stream);
}
项目:spring-boot-concourse    文件:WarCommand.java   
@Override
protected void addCliClasses(JarWriter writer) throws IOException {
    addClass(writer, null, "org.springframework.boot."
            + "cli.app.SpringApplicationWebApplicationInitializer");
    super.addCliClasses(writer);
}
项目:spring-boot-concourse    文件:ArchiveCommand.java   
protected final void addClass(JarWriter writer, Class<?> sourceClass)
        throws IOException {
    addClass(writer, sourceClass.getClassLoader(), sourceClass.getName());
}
项目:spring-boot-concourse    文件:ArchiveCommand.java   
private void addResource(JarWriter writer, Resource resource, String name)
        throws IOException {
    InputStream stream = resource.getInputStream();
    writer.writeEntry(name, stream);
}
项目:contestparser    文件:WarCommand.java   
@Override
protected void addCliClasses(JarWriter writer) throws IOException {
    addClass(writer, null, "org.springframework.boot."
            + "cli.app.SpringApplicationWebApplicationInitializer");
    super.addCliClasses(writer);
}
项目:contestparser    文件:ArchiveCommand.java   
protected final void addClass(JarWriter writer, Class<?> sourceClass)
        throws IOException {
    addClass(writer, sourceClass.getClassLoader(), sourceClass.getName());
}
项目:contestparser    文件:ArchiveCommand.java   
private void addResource(JarWriter writer, Resource resource, String name)
        throws IOException {
    InputStream stream = resource.getInputStream();
    writer.writeEntry(name, stream);
}