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()); }
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())); } }
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); } } }); }