Created
January 25, 2012 11:49
-
-
Save wolfc/1675926 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.File; | |
import java.lang.RuntimeException; | |
import java.lang.String; | |
import java.util.ArrayList; | |
import java.util.Collection; | |
import java.util.Collections; | |
import java.util.List; | |
public class build { | |
private static void compile(final Collection<String> options) { | |
final int result = com.sun.tools.javac.Main.compile(options.toArray(new String[0])); | |
if (result != 0) | |
throw new RuntimeException("Compilation failed"); | |
} | |
private static Collection<String> filesIn(final String directoryName) { | |
final Collection<String> files = new ArrayList<String>(); | |
final File directory = new File(directoryName); | |
if (!directory.isDirectory()) | |
return Collections.EMPTY_LIST; | |
for (File file : directory.listFiles()) { | |
if (file.isDirectory()) | |
files.addAll(filesIn(file.getAbsolutePath())); | |
else | |
files.add(file.getAbsolutePath()); | |
} | |
return files; | |
} | |
private static void jar(final String... args) { | |
sun.tools.jar.Main.main(args); | |
} | |
public static void main(final String[] args) throws Exception { | |
new File("target/classes").mkdirs(); | |
// javac -sourcepath src/main/java -d target/classes `find src/main/java -name *.java` | |
final List<String> compilerArgs = new ArrayList<String>(); | |
compilerArgs.add("-sourcepath"); | |
compilerArgs.add("src/main/java"); | |
compilerArgs.add("-d"); | |
compilerArgs.add("target/classes"); | |
compilerArgs.addAll(filesIn("src/main/java")); | |
compile(compilerArgs); | |
//jar cvfe target/jboss-noxius-bootstrap.jar org.jboss.noxius.bootstrap.Bootstrap -C target/classes/ . | |
jar("cvfe", "target/jboss-noxius-bootstrap.jar", "org.jboss.noxius.bootstrap.Bootstrap", "-C", "target/classes/", "."); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment