JScratch
Loading...
Searching...
No Matches
JarExporter.java
Go to the documentation of this file.
1package com.jscratch.compiler;
2
3import java.io.*;
4import java.nio.file.*;
5import java.util.jar.*;
6import java.util.zip.*;
7
11public class JarExporter {
12
13 public static void export(File targetJar, File compiledClassesDir, File sourceDir) throws IOException {
14 try (JarOutputStream jos = new JarOutputStream(new FileOutputStream(targetJar))) {
15 // Add manifest
16 Manifest manifest = new Manifest();
17 manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0");
18 manifest.getMainAttributes().put(Attributes.Name.MAIN_CLASS, "com.jscratch.MainRunner");
19
20 // ... logic to walk and add all files from compiledClassesDir and sourceDir ...
21 }
22 }
23}
static void export(File targetJar, File compiledClassesDir, File sourceDir)