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

项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:RepackageTask.java   
private void repackage(File file) {
    File outputFile = RepackageTask.this.outputFile;
    if (outputFile != null && !file.equals(outputFile)) {
        copy(file, outputFile);
        file = outputFile;
    }
    Repackager repackager = new LoggingRepackager(file);
    setMainClass(repackager);
    if (this.extension.convertLayout() != null) {
        repackager.setLayout(this.extension.convertLayout());
    }
    repackager.setBackupSource(this.extension.isBackupSource());
    try {
        LaunchScript launchScript = getLaunchScript();
        repackager.repackage(file, this.libraries, launchScript);
    }
    catch (IOException ex) {
        throw new IllegalStateException(ex.getMessage(), ex);
    }
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:RepackageTask.java   
private void setMainClass(Repackager repackager) {
    String mainClassName = getMainClassNameProperty();
    if (RepackageTask.this.mainClass != null) {
        mainClassName = RepackageTask.this.mainClass;
    }
    else if (this.extension.getMainClass() != null) {
        mainClassName = this.extension.getMainClass();
    }
    else {
        Task runTask = getProject().getTasks().findByName("run");
        if (runTask != null && runTask.hasProperty("main")) {
            mainClassName = (String) getProject().getTasks().getByName("run")
                    .property("main");
        }
    }
    if (mainClassName != null) {
        getLogger().info("Setting mainClass: " + mainClassName);
        repackager.setMainClass(mainClassName);
    }
    else {
        getLogger().info("No mainClass configured");
    }
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:RepackageMojo.java   
private void repackage() throws MojoExecutionException {
    File source = this.project.getArtifact().getFile();
    File target = getTargetFile();
    Repackager repackager = getRepackager(source);
    Set<Artifact> artifacts = filterDependencies(this.project.getArtifacts(),
            getFilters(getAdditionalFilters()));
    Libraries libraries = new ArtifactsLibraries(artifacts, this.requiresUnpack,
            getLog());
    try {
        LaunchScript launchScript = getLaunchScript();
        repackager.repackage(target, libraries, launchScript);
    }
    catch (IOException ex) {
        throw new MojoExecutionException(ex.getMessage(), ex);
    }
    updateArtifact(source, target, repackager.getBackupFile());
}
项目:spring-boot-concourse    文件:RepackageTask.java   
private void repackage(File file) {
    File outputFile = RepackageTask.this.outputFile;
    if (outputFile != null && !file.equals(outputFile)) {
        copy(file, outputFile);
        file = outputFile;
    }
    Repackager repackager = new LoggingRepackager(file);
    setMainClass(repackager);
    if (this.extension.convertLayout() != null) {
        repackager.setLayout(this.extension.convertLayout());
    }
    repackager.setBackupSource(this.extension.isBackupSource());
    try {
        LaunchScript launchScript = getLaunchScript();
        repackager.repackage(file, this.libraries, launchScript);
    }
    catch (IOException ex) {
        throw new IllegalStateException(ex.getMessage(), ex);
    }
}
项目:spring-boot-concourse    文件:RepackageTask.java   
private void setMainClass(Repackager repackager) {
    String mainClassName = getMainClassNameProperty();
    if (RepackageTask.this.mainClass != null) {
        mainClassName = RepackageTask.this.mainClass;
    }
    else if (this.extension.getMainClass() != null) {
        mainClassName = this.extension.getMainClass();
    }
    else {
        Task runTask = getProject().getTasks().findByName("run");
        if (runTask != null && runTask.hasProperty("main")) {
            mainClassName = (String) getProject().getTasks().getByName("run")
                    .property("main");
        }
    }
    getLogger().info("Setting mainClass: " + mainClassName);
    repackager.setMainClass(mainClassName);
}
项目:spring-boot-concourse    文件:RepackageMojo.java   
private void repackage() throws MojoExecutionException {
    File source = this.project.getArtifact().getFile();
    File target = getTargetFile();
    Repackager repackager = getRepackager(source);
    Set<Artifact> artifacts = filterDependencies(this.project.getArtifacts(),
            getFilters(getAdditionalFilters()));
    Libraries libraries = new ArtifactsLibraries(artifacts, this.requiresUnpack,
            getLog());
    try {
        LaunchScript launchScript = getLaunchScript();
        repackager.repackage(target, libraries, launchScript);
    }
    catch (IOException ex) {
        throw new MojoExecutionException(ex.getMessage(), ex);
    }
    updateArtifact(source, target, repackager.getBackupFile());
}
项目:cft    文件:JarArchivingUIHandler.java   
protected void bootRepackage(final IPackageFragmentRoot[] roots, File packagedFile) throws CoreException {
    Repackager bootRepackager = new Repackager(packagedFile);
    try {
        bootRepackager.repackage(new Libraries() {

            public void doWithLibraries(LibraryCallback callBack) throws IOException {
                for (IPackageFragmentRoot root : roots) {

                    if (root.isArchive()) {

                        File rootFile = new File(root.getPath().toOSString());
                        if (rootFile.exists()) {
                            callBack.library(new Library(rootFile, LibraryScope.COMPILE));
                        }
                    }
                }
            }
        });
    } catch (IOException e) {
        errorHandler.handleApplicationDeploymentFailure(
                NLS.bind(Messages.JavaCloudFoundryArchiver_ERROR_REPACKAGE_SPRING, e.getMessage()));
    }
}
项目:contestparser    文件:RepackageTask.java   
private void repackage(File file) {
    File outputFile = RepackageTask.this.outputFile;
    if (outputFile != null && !file.equals(outputFile)) {
        copy(file, outputFile);
        file = outputFile;
    }
    Repackager repackager = new LoggingRepackager(file);
    setMainClass(repackager);
    if (this.extension.convertLayout() != null) {
        repackager.setLayout(this.extension.convertLayout());
    }
    repackager.setBackupSource(this.extension.isBackupSource());
    try {
        LaunchScript launchScript = getLaunchScript();
        repackager.repackage(file, this.libraries, launchScript);
    }
    catch (IOException ex) {
        throw new IllegalStateException(ex.getMessage(), ex);
    }
}
项目:contestparser    文件:RepackageTask.java   
private void setMainClass(Repackager repackager) {
    String mainClass;
    if (getProject().hasProperty("mainClassName")) {
        mainClass = (String) getProject().property("mainClassName");
    }
    else {
        ExtraPropertiesExtension extraProperties = (ExtraPropertiesExtension) getProject()
                .getExtensions().getByName("ext");
        mainClass = (String) extraProperties.get("mainClassName");
    }
    if (RepackageTask.this.mainClass != null) {
        mainClass = RepackageTask.this.mainClass;
    }
    else if (this.extension.getMainClass() != null) {
        mainClass = this.extension.getMainClass();
    }
    else {
        Task runTask = getProject().getTasks().findByName("run");
        if (runTask != null && runTask.hasProperty("main")) {
            mainClass = (String) getProject().getTasks().getByName("run")
                    .property("main");
        }
    }
    getLogger().info("Setting mainClass: " + mainClass);
    repackager.setMainClass(mainClass);
}
项目: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    文件:RepackageMojo.java   
private Repackager getRepackager(File source) {
    Repackager repackager = new LoggingRepackager(source, getLog());
    repackager.setMainClass(this.mainClass);
    if (this.layout != null) {
        getLog().info("Layout: " + this.layout);
        repackager.setLayout(this.layout.layout());
    }
    return repackager;
}
项目: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    文件:RepackageMojo.java   
private Repackager getRepackager(File source) {
    Repackager repackager = new LoggingRepackager(source, getLog());
    repackager.setMainClass(this.mainClass);
    if (this.layout != null) {
        getLog().info("Layout: " + this.layout);
        repackager.setLayout(this.layout.layout());
    }
    return repackager;
}
项目: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);
            }
        }
    });
}