Added build code for OAK
This commit is contained in:
parent
c307a406e6
commit
d52a1ac8f6
|
@ -0,0 +1,51 @@
|
|||
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import dorkbox.Build;
|
||||
import dorkbox.license.License;
|
||||
import dorkbox.util.FileUtil;
|
||||
|
||||
public class BuildStrings {
|
||||
|
||||
// this is the ROOT name for this project and for the launcher. This is necessary because of how class parsing is done
|
||||
public static final String Dir_Pattern = "./";
|
||||
|
||||
public static final String STAGING = "staging";
|
||||
|
||||
public static class ProjectPath {
|
||||
public static final String Resources = Build.path("..", "..", "resources");
|
||||
public static final String GitHub = Build.path("..", "..", "github_projects");
|
||||
}
|
||||
|
||||
public static class JavaBuilder {
|
||||
public static final String name = "OAK";
|
||||
public static final String root = path(BuildStrings.ProjectPath.GitHub, name);
|
||||
public static final String src = path(root, "src");
|
||||
public static ArrayList<License> license = new ArrayList<License>() {
|
||||
private static final long serialVersionUID = 1L;
|
||||
{
|
||||
add(Licenses.OAK.OAK);
|
||||
add(Licenses.OAK.Scar);
|
||||
add(Licenses.DorkboxUtil.DorkboxUtil);
|
||||
add(Licenses.DorkboxUtil.MigBase64);
|
||||
add(Licenses.DorkboxUtil.FilenameUtils);
|
||||
add(Licenses.DorkboxUtil.AnnotationDetector);
|
||||
|
||||
add(LicenseLibs.BouncyCastle);
|
||||
add(LicenseLibs.FastMD5);
|
||||
add(LicenseLibs.LzmaJava);
|
||||
add(LicenseLibs.SLF4J);
|
||||
|
||||
add(LicenseLibs.JavaTar);
|
||||
add(LicenseLibs.WildCard);
|
||||
add(LicenseLibs.OpenJDK);
|
||||
add(LicenseLibs.YamlBeans);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private static String path(String... path) {
|
||||
return FileUtil.normalizeAsFile(Build.path(path));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
import dorkbox.Build;
|
||||
|
||||
// setup source directories
|
||||
public class Dirs {
|
||||
public static final String Dependencies = Build.path(BuildStrings.ProjectPath.Resources, "Dependencies");
|
||||
|
||||
public static final String JavaTar = mkDir("javatar");
|
||||
public static final String YAML = mkDir("yaml");
|
||||
public static final String WildCard = mkDir("wildcard");
|
||||
public static final String LzmaJava = mkDir("lzma-java");
|
||||
|
||||
public static final String Java_Redist = Build.path(BuildStrings.ProjectPath.Resources, "Java_Redist");
|
||||
public static final String OpenJDK_Runtime = Build.path(Java_Redist, "openJDK_runtime");
|
||||
|
||||
public static String mkDir(String dir) {
|
||||
return Build.path(Dependencies, dir);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
|
||||
|
||||
import dorkbox.license.License;
|
||||
import dorkbox.license.LicenseType;
|
||||
|
||||
public class LicenseLibs {
|
||||
|
||||
public static final License
|
||||
BouncyCastle = new License("BouncyCastle", LicenseType.MIT)
|
||||
.u("http://www.bouncycastle.org")
|
||||
.c("Copyright 2000-2009, The Legion Of The Bouncy Castle");
|
||||
|
||||
public static final License
|
||||
FastMD5 = new License("FastMD5", LicenseType.LGPLv3)
|
||||
.u("http://www.twmacinta.com/myjava/fast_md5.php")
|
||||
.c("Copyright 1996, Santeri Paavolainen, Helsinki Finland")
|
||||
.c("Many changes Copyright 2002 - 2010 Timothy W Macinta")
|
||||
.n("Originally written by Santeri Paavolainen, Helsinki Finland 1996");
|
||||
|
||||
public static final License
|
||||
JavaTar = new License("Javatar", LicenseType.PUBLIC)
|
||||
.u("http://www.trustice.com/java/tar")
|
||||
.c("Timothy Gerard Endres, time@gjt.org");
|
||||
|
||||
public static final License
|
||||
LzmaJava = new License("LZMA-Java", LicenseType.APACHE)
|
||||
.u("http://jponge.github.com/lzma-java")
|
||||
.c("http://www.7-zip.org/sdk.html")
|
||||
.c("Copyright 2014 Igor Pavlov")
|
||||
.a("Julien Ponge (julien.ponge@gmail.com)");
|
||||
|
||||
public static final License
|
||||
OpenJDK = new License("OpenJDK", LicenseType.GPLv2_CP)
|
||||
.u("http://openjdk.java.net")
|
||||
.u("https://github.com/alexkasko/openjdk-unofficial-builds")
|
||||
.c("Copyright 2007, Sun Microsystems, Inc")
|
||||
.n("http://www.gnu.org/software/classpath/license.html")
|
||||
.n(" When GNU Classpath is used unmodified as the core class library for a virtual machine,")
|
||||
.n(" compiler for the java language, or for a program written in the java programming language")
|
||||
.n(" it does not affect the licensing for distributing those programs directly.");
|
||||
|
||||
public static final License
|
||||
SLF4J = new License("SLF4J", LicenseType.MIT)
|
||||
.u("http://www.slf4j.org/")
|
||||
.c("Copyright 2004-2008, QOS.ch");
|
||||
|
||||
public static final License
|
||||
WildCard = new License("Wildcard", LicenseType.BSD)
|
||||
.u("https://github.com/EsotericSoftware/wildcard")
|
||||
.c("Copyright 2008, Nathan Sweet");
|
||||
|
||||
public static final License
|
||||
YamlBeans = new License("YamlBeans", LicenseType.BSD)
|
||||
.u("https://github.com/EsotericSoftware/yamlbeans")
|
||||
.c("Copyright 2006, Ola Bini")
|
||||
.c("Copyright 2008, Nathan Sweet");
|
||||
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
|
||||
|
||||
import dorkbox.license.License;
|
||||
import dorkbox.license.LicenseType;
|
||||
|
||||
// these are licenese's that are have code embedded into the various projects
|
||||
public class Licenses {
|
||||
public static class OAK {
|
||||
public static final License
|
||||
OAK = new License("Dorkbox OAK", LicenseType.APACHE)
|
||||
.u("https://github.com/dorkbox")
|
||||
.c("Copyright 2012, dorkbox, llc")
|
||||
.n("Java project management and build tool, using the Java language");
|
||||
|
||||
public static final License
|
||||
Scar = new License("Scar", LicenseType.BSD)
|
||||
.u("https://github.com/EsotericSoftware/scar")
|
||||
.c("Copyright 2011, Nathan Sweet");
|
||||
}
|
||||
|
||||
public static class DorkboxUtil {
|
||||
public static final License
|
||||
AnnotationDetector = new License("AnnotationDetector", LicenseType.APACHE)
|
||||
.u("https://github.com/rmuller/infomas-asl")
|
||||
.c("Copyright 2011 - 2014, XIAM Solutions B.V. (http://www.xiam.nl)");
|
||||
|
||||
public static final License
|
||||
DorkboxUtil = new License("Dorkbox Utils", LicenseType.APACHE)
|
||||
.u("https://github.com/dorkbox")
|
||||
.c("Copyright 2010, dorkbox, llc");
|
||||
|
||||
public static final License
|
||||
FilenameUtils = new License("FilenameUtils.java (normalize + dependencies)", LicenseType.APACHE)
|
||||
.u("http://commons.apache.org/proper/commons-io/")
|
||||
.c("Copyright 2013, ASF")
|
||||
.a("Kevin A. Burton").a("Scott Sanders").a("Daniel Rall").a("Christoph.Reck")
|
||||
.a("Peter Donald").a("Jeff Turner").a("Matthew Hawthorne").a("Martin Cooper")
|
||||
.a("Jeremias Maerki").a("Stephen Colebourne");
|
||||
|
||||
public static final License
|
||||
MigBase64 = new License("MiG Base64", LicenseType.BSD)
|
||||
.u("http://migbase64.sourceforge.net/")
|
||||
.c("Copyright 2004, Mikael Grev, MiG InfoCom AB. (base64@miginfocom.com)")
|
||||
.n("High performance base64 encoder & decoder");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,227 @@
|
|||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
|
||||
import javassist.ClassPool;
|
||||
import javassist.CtClass;
|
||||
import javassist.CtMethod;
|
||||
|
||||
import com.esotericsoftware.wildcard.Paths;
|
||||
|
||||
import dorkbox.Build;
|
||||
import dorkbox.BuildOptions;
|
||||
import dorkbox.build.ProjectBasics;
|
||||
import dorkbox.build.ProjectJava;
|
||||
import dorkbox.build.util.PreJarAction;
|
||||
import dorkbox.license.License;
|
||||
import dorkbox.util.FileUtil;
|
||||
import dorkbox.util.LocationResolver;
|
||||
|
||||
@Build.Builder
|
||||
public class OAK {
|
||||
|
||||
// ~/dorkbox/eclipse/jre/bin/java -jar dist/OAK.jar build oak
|
||||
// ~/dorkbox/eclipse/jre/bin/java -Xrunjdwp:transport=dt_socket,server=y,address=1044 -jar dist/OAK.jar build oak
|
||||
|
||||
|
||||
public static void build(BuildOptions buildOptions) throws Exception {
|
||||
// Unsafe creates compiler warnings. Disable them!
|
||||
buildOptions.compiler.suppressSunWarnings = true;
|
||||
|
||||
buildOptions.compiler.targetJavaVersion = 6;
|
||||
|
||||
buildOptions.compiler.forceRebuild = true;
|
||||
buildOptions.compiler.deleteOnComplete = true;
|
||||
buildOptions.compiler.jar.buildJar = true;
|
||||
|
||||
|
||||
// if we are running from a jar, DO NOT try to do certain things
|
||||
String utilSourcePath = LocationResolver.get(dorkbox.Build.class).getAbsolutePath();
|
||||
boolean runningFromJar = utilSourcePath.endsWith(".jar");
|
||||
|
||||
if (!runningFromJar) {
|
||||
// install license files
|
||||
License.install(BuildStrings.JavaBuilder.root, BuildStrings.JavaBuilder.license);
|
||||
}
|
||||
|
||||
String distDir = FileUtil.normalizeAsFile(Build.path(BuildStrings.JavaBuilder.root, "dist"));
|
||||
File dists = new File(distDir);
|
||||
dists.mkdirs();
|
||||
|
||||
|
||||
String libsPath = FileUtil.normalizeAsFile(Build.path(BuildStrings.JavaBuilder.root, "libs"));
|
||||
if (!runningFromJar) {
|
||||
// copy over jar deps
|
||||
File libDir = new File(libsPath);
|
||||
libDir.mkdirs();
|
||||
|
||||
Build.copyDirectory(Dirs.JavaTar, libsPath);
|
||||
Build.copyDirectory(Dirs.YAML, libsPath);
|
||||
Build.copyDirectory(Dirs.WildCard, libsPath);
|
||||
|
||||
List<File> parseDir = FileUtil.parseDir(Build.path(Dirs.Dependencies, "logging"));
|
||||
for (File next : parseDir) {
|
||||
String name = next.getName();
|
||||
if (name.startsWith("slf4j") ||
|
||||
name.startsWith("logback-classic") ||
|
||||
name.startsWith("logback-cored")) {
|
||||
|
||||
File file = new File(libDir, name);
|
||||
FileUtil.copyFile(next, file);
|
||||
}
|
||||
}
|
||||
|
||||
parseDir = FileUtil.parseDir(Build.path(Dirs.Dependencies, "BouncyCastleCrypto"));
|
||||
for (File next : parseDir) {
|
||||
String name = next.getName();
|
||||
if ((name.endsWith(".jar") || name.endsWith(".zip")) &&
|
||||
(name.startsWith("bcpkix-jdk15on-") || name.startsWith("bcprov-jdk15on-"))) {
|
||||
|
||||
File file = new File(libDir, name);
|
||||
Build.copyFile(next, file);
|
||||
}
|
||||
}
|
||||
|
||||
parseDir = FileUtil.parseDir(Build.path(Dirs.Dependencies, "lzma-java"));
|
||||
for (File next : parseDir) {
|
||||
String name = next.getName();
|
||||
if (name.startsWith("lzma-java")) {
|
||||
File file = new File(libDir, name);
|
||||
Build.copyFile(next, file);
|
||||
}
|
||||
}
|
||||
|
||||
Build.copyDirectory(Build.path(Dirs.Dependencies, "fast-md5"), FileUtil.normalize(Build.path(libsPath, "fast-md5")));
|
||||
|
||||
// copy over the rt.jars for different versions of java, so we can 'cross compile' for different targets
|
||||
String jdkDist = FileUtil.normalize(Build.path(libsPath, "jdkRuntimes"));
|
||||
Build.copyDirectory(Dirs.OpenJDK_Runtime, jdkDist);
|
||||
}
|
||||
|
||||
// now create the dorkboxUtil.jar jar + source + license
|
||||
|
||||
if (!runningFromJar) {
|
||||
Paths sources = new Paths();
|
||||
sources.add(Build.getClassPath(dorkbox.util.OS.class));
|
||||
sources.add(Build.getClassPath(dorkbox.util.OsType.class));
|
||||
sources.add(Build.getClassPath(dorkbox.util.FileUtil.class)); // also apache filename utils
|
||||
sources.add(Build.getClassPath(dorkbox.util.LZMA.class)); // LZMA
|
||||
sources.add(Build.getClassPath(dorkbox.util.Sys.class));
|
||||
|
||||
// have to specifiy a class in the package we want to get
|
||||
sources.add(Build.getClassPathPackage(dorkbox.util.annotation.AnnotationDetector.class)); // annotation detector
|
||||
|
||||
sources.add(Build.getClassPath(dorkbox.util.CountingLatch.class));
|
||||
|
||||
sources.add(Build.getClassPath(dorkbox.util.properties.SortedProperties.class));
|
||||
sources.add(Build.getClassPath(dorkbox.util.properties.PropertiesProvider.class));
|
||||
|
||||
// have to specifiy a class in the package we want to get
|
||||
sources.add(Build.getClassPathPackage(dorkbox.util.process.ProcessProxy.class));
|
||||
|
||||
sources.add(Build.getClassPath(dorkbox.util.Base64Fast.class)); //Base64 mig
|
||||
sources.add(Build.getClassPath(dorkbox.util.crypto.Crypto.class));
|
||||
sources.add(Build.getClassPath(dorkbox.util.crypto.CryptoX509.class));
|
||||
|
||||
sources.add(Build.getClassPath(dorkbox.util.gwt.GwtSymbolMapParser.class));
|
||||
|
||||
sources.add(Build.getClassPath(dorkbox.util.LocationResolver.class));
|
||||
|
||||
PreJarAction preJarAction = new PreJarAction() {
|
||||
@Override
|
||||
public void executeBeforeJarHappens(String outputDir) throws Exception {
|
||||
ClassPool cp = ClassPool.getDefault();
|
||||
InputStream ins = null;
|
||||
try {
|
||||
// removing netty requirement from crypto, as only VERY LITTLE is needed by us!
|
||||
File file = new File(outputDir, Build.path("dorkbox", "util", "crypto", "Crypto$AES.class"));
|
||||
ins = new FileInputStream(file);
|
||||
CtClass cryptoClass = cp.makeClass(ins);
|
||||
CtMethod[] methods = cryptoClass.getMethods();
|
||||
for (CtMethod method : methods) {
|
||||
String name = method.getName();
|
||||
|
||||
if (name.equals("encrypt") || name.equals("decrypt")) {
|
||||
CtClass[] parameterTypes = method.getParameterTypes();
|
||||
if (parameterTypes.length > 0 &&
|
||||
parameterTypes[0].getName().equals("dorkbox.util.crypto.bouncycastle.GCMBlockCipher_ByteBuf")) {
|
||||
cryptoClass.removeMethod(method);
|
||||
}
|
||||
}
|
||||
}
|
||||
cryptoClass.writeFile(outputDir);
|
||||
} finally {
|
||||
if (ins != null) {
|
||||
ins.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// this is only done here, since this is a VERY limited version of our utils.
|
||||
ProjectJava project = ProjectJava.create("DorkboxUtil")
|
||||
.includeSourceInJar()
|
||||
.license(Licenses.DorkboxUtil.DorkboxUtil)
|
||||
.license(Licenses.DorkboxUtil.MigBase64)
|
||||
.license(Licenses.DorkboxUtil.FilenameUtils)
|
||||
.preJarAction(preJarAction)
|
||||
.sourcePath(sources);
|
||||
|
||||
project.build(buildOptions);
|
||||
// now put it in our libs
|
||||
Build.copyFile(Build.path("staging", project.outputFile), Build.path(libsPath, "dorkboxUtil.jar"));
|
||||
}
|
||||
|
||||
|
||||
PreJarAction preJarAction = new PreJarAction() {
|
||||
@Override
|
||||
public void executeBeforeJarHappens(String outputDir) throws Exception {
|
||||
Build.log().message("Installing license files...");
|
||||
File targetLocation = new File(outputDir, Build.path("dorkbox", "license"));
|
||||
License.install(targetLocation);
|
||||
}
|
||||
};
|
||||
|
||||
// now build the project
|
||||
ProjectJava project = ProjectJava.create(BuildStrings.JavaBuilder.name)
|
||||
.classPath(new Paths(Build.path(BuildStrings.JavaBuilder.root, "libs"), ProjectBasics.Jar_Pattern, "!jdkRuntimes"))
|
||||
.includeSourceInJar()
|
||||
.preJarAction(preJarAction)
|
||||
|
||||
.license(BuildStrings.JavaBuilder.license)
|
||||
.extraFiles(new Paths(BuildStrings.JavaBuilder.root, "README.md"))
|
||||
.mainClass(dorkbox.Build.class)
|
||||
.sourcePath(BuildStrings.JavaBuilder.src, ProjectBasics.Java_Pattern);
|
||||
|
||||
|
||||
project.build(buildOptions);
|
||||
|
||||
// now put it in our dist dir
|
||||
String targetPath = Build.path(distDir, project.name + ".jar");
|
||||
Build.moveFile(Build.path(BuildStrings.STAGING, project.outputFile), targetPath);
|
||||
|
||||
|
||||
// now copy all of these files into our libs dir for our builder
|
||||
if (!runningFromJar){
|
||||
// ALSO copy this file into OUR libs dir (so we can use it!)
|
||||
File rootPath = LocationResolver.get(OAK.class);
|
||||
String destLibsDir = new File(rootPath.getParentFile(), "libs").getAbsolutePath();
|
||||
|
||||
// ALSO copy this file into OUR libs dir (so we can use it!)
|
||||
Build.log().message("Copying jars into our location.");
|
||||
Build.copyFile(targetPath, Build.path(destLibsDir, project.name + ".jar"));
|
||||
|
||||
// copy all of the files from the libs dir
|
||||
FileUtil.copyDirectory(libsPath, destLibsDir);
|
||||
|
||||
|
||||
// and the license files
|
||||
Build.log().message("Copying license files to our location.");
|
||||
Paths paths = new Paths(BuildStrings.JavaBuilder.root, "LICENSE*");
|
||||
for (File file : paths.getFiles()) {
|
||||
FileUtil.copyFile(file.getAbsolutePath(), Build.path(destLibsDir, file.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
name: OAK
|
||||
classpath:
|
||||
- ../../resources/Dependencies/javassist/javassist.jar
|
||||
|
||||
source:
|
||||
- src/**/*.java
|
Loading…
Reference in New Issue