My favorites | Sign in
Project Home Downloads Wiki Issues Source
Project Information
Members

PJMake is a build tool that uses a pure Java build definition. It is like Apache Ant, but instead of build.xml, the build file is called Build.java.

To use PJMake in your application:

  • Add a copy of the file BuildBase.java to your application. Change the package to <com.acme>.build, where com.acme is the package of your main classes.
  • Add a copy of the files build.bat and build.sh to your application (usually in the root directory). Those are used to bootstrap and run the build. You will have to change the package.
  • Write a class Build.java (example see below). This class extends BuildBase and contains your build targets.
  • Run the build: run 'build.bat' or './build.sh'.

An example build definition looks like this:

package org.pjmake;

import java.io.File;

/**
 * The build definition.
 */
public class Build extends BuildBase {

    public static void main(String[] args) {
        new Build().run(args);
    }

    public void all() {
        compile();
        test();
        javadoc();
        jar();
    }
    
    public void clean() {
        delete("temp");
        delete("docs");
        mkdir("docs");
        mkdir("bin");
    }
    
    public void compile() {
        clean();
        mkdir("temp");
        download();
        String classpath = "temp" + 
                File.pathSeparator + 
                "ext/junit-4.4.jar" + 
                File.pathSeparator + 
                System.getProperty("java.home") + 
                "/../lib/tools.jar";
        FileList files = getFiles("src/main");
        javac(new String[] { 
                "-d", "temp", 
                "-sourcepath", "src/main", 
                "-classpath", classpath }, files);
    }

    public void download() {
        download("ext/junit-3.8.2.jar",
                "http://repo1.maven.org/maven2/junit/junit/3.8.2/junit-3.8.2.jar",
                "07e4cde26b53a9a0e3fe5b00d1dbbc7cc1d46060");
    }
    
    private String getVersion() {
        return getStaticField(
                "org.pjmake.demo.HelloWorld", 
                "VERSION");
    }
    
    public void jar() {
        FileList files = getFiles("temp");
        jar("bin/pjmake-" + getVersion() + ".jar", 
                files, "temp");
    }
    
    public void javadoc() {
        delete("docs");
        mkdir("docs/javadoc");
        javadoc(new String[] { 
                "-sourcepath", "src/main" + 
                File.pathSeparator + "src/tools", 
                "-d", "docs", 
                "org.pjmake.demo", "org.pjmake" });
    }        
    
    public void test() {
        junit(new String[] { "org.pjmake.test.TestAll" });
    }
    
    public void zip() {
        FileList files = getFiles("../pjmake").keep("../pjmake/build.*");
        files.addAll(getFiles("../pjmake/docs"));
        files.addAll(getFiles("../pjmake/src"));
        zip("../pjmake.zip", files, "../", false, false);
    }
    
}
Powered by Google Project Hosting