import java.io.File
import java.text.SimpleDateFormat
import java.util.Date
import org.entityfs.util.*
import org.entityfs.util.filter.entity.*
import org.schmant.run.TaskExecutor
import org.schmant.support.entityfs.*
import org.schmant.support.io.*
import org.schmant.task.io.TreeCopyTF
import org.schmant.task.jdk.jar.JarTF
import org.schmant.task.jdk.javac.jdk6.Jdk6JavacTF
// A temporary directory for the compiled classes. This, along with all of its
// contents, will be automatically deleted when Schmant exits (unless the -k
// flag is used).
def ctarget =
TempFileUtil.createTempDir()
// The lib directory that contains Jar files that the code to compile uses.
def libDir =
SchmantFileSystems.getEntityForDirectory(
new
File("/home/me/myproject/lib"), true)
// Get all jar files from the lib directory. The jar files are returned as a
//
Set of EntityFS
EFile:s
def depjars =
Directories.getAllFilesMatching(libDir, "*.jar")
// Add a dependency from the optlib directory. This is a Java
File
depjars.add(new
File("/home/me/myproject/optlib/opt.jar"))
// Create a read only, locking
Directory object for the source directory.
// A locking file system eliminates the risk of accidental concurrent
// modification of files by parallel build threads.
def src =
SchmantFileSystems.getEntityForDirectory(
new
File("/home/me/myproject/src"),
true)
// Create a task executor that, by default, will use two build threads, unless
// the noOfBuildThreads property is set to another value.
def te = new
TaskExecutor().
setNumberOfThreads(props.getIntValue("noOfBuildThreads", 2)).
start()
try {
// A task for compiling all source files
//
TaskExecutor.add returns a
TaskDependency object for the added task.
def javacDep = te.add(
new
Jdk6JavacTF().
addSource(src).
addClasspathEntries(depjars).
setTarget(ctarget))
// A task for copying all non-Java files from the source hierarchy to the
// target hierarchy.
def copyDep = te.add(
new
TreeCopyTF().
// Create a view of the source hierarchy that hides all .java files.
setSource(
src.newView(
// Groovy lets us use the ~ operator to negate the filter.
~ new
EFileNameExtensionFilter("java"))).
setTarget(ctarget))
// A timestamp for the built archive
def timestamp = new
SimpleDateFormat("yyyyMMddHHmm").
format(new
Date())
// Build the Jar file. Put it in /home/me/myproject
// The Jar build task depends on both the compiling and the copying tasks.
te.add(
new
JarTF().
addSource(ctarget).
setTarget(new
File("/home/me/myproject/myproject" + timestamp + ".jar")),
// Use an array for the two dependencies.
[javacDep, copyDep])
// Wait for all tasks to complete
te.waitFor()
} finally {
te.shutdown()
}
// A temporary directory for the compiled classes. This, along with all of its
// contents, will be automatically deleted when Schmant exits (unless the -k
// flag is used).
ctarget =
TempFileUtil.createTempDir();
// The lib directory that contains Jar files that the code to compile uses.
libDir =
SchmantFileSystems.getEntityForDirectory(
new
File("/home/me/myproject/lib"), true);
// Get all jar files from the lib directory. The jar files are returned as a
//
Set of EntityFS
EFile:s
depjars =
Directories.getAllFilesMatching(libDir, "*.jar");
// Add a dependency from the optlib directory. This is a Java
File
depjars.add(new
File("/home/me/myproject/optlib/opt.jar"));
// Create a read only, locking
Directory object for the source directory.
// A locking file system eliminates the risk of accidental concurrent
// modification of files by parallel build threads.
src =
SchmantFileSystems.getEntityForDirectory(
new
File("/home/me/myproject/src"),
true);
// Create a task executor that, by default, will use two build threads, unless
// the noOfBuildThreads property is set to another value.
te = new
TaskExecutor().
setNumberOfThreads(props.getIntValue("noOfBuildThreads", 2)).
start();
try {
// A task for compiling all source files
//
TaskExecutor.add returns a
TaskDependency object for the added task.
javacDep = te.add(
new
Jdk6JavacTF().
addSource(src).
addClasspathEntries(depjars).
setTarget(ctarget));
// A task for copying all non-Java files from the source hierarchy to the
// target hierarchy.
copyDep = te.add(
new
TreeCopyTF().
// Create a view of the source hierarchy that hides all .java files.
setSource(
src.newView(
new
EFileNameExtensionFilter("java").not())).
setTarget(ctarget));
// A timestamp for the built archive
timestamp = new Packages.java.text.SimpleDateFormat("yyyyMMddHHmm").
format(new
Date());
// Build the Jar file. Put it in /home/me/myproject
// The Jar build task depends on both the compiling and the copying tasks.
te.add(
new
JarTF().
addSource(ctarget).
setTarget(new
File("/home/me/myproject/myproject" + timestamp + ".jar")),
// Use an array for the two dependencies
[javacDep, copyDep]);
// Wait for all tasks to complete
te.waitFor();
} finally {
te.shutdown();
}
# A temporary directory for the compiled classes. This, along with all of its
# contents, will be automatically deleted when Schmant exits (unless the -k
# flag is used).
ctarget = Schmant::
TempFileUtil.createTempDir
# The lib directory that contains Jar files that the code to compile uses.
libDir = Schmant::
SchmantFileSystems.getEntityForDirectory(
Java::JavaIo::
File.new("/home/me/myproject/lib"), true)
# Get all jar files from the lib directory. The jar files are returned as a
#
Set of EntityFS
EFile:s
depjars = Schmant::
Directories.getAllFilesMatching(libDir, "*.jar")
# Add a dependency from the optlib directory. This is a Java
File
depjars.add Java::JavaIo::
File.new("/home/me/myproject/optlib/opt.jar")
# Create a read only, locking
Directory object for the source directory.
# A locking file system eliminates the risk of accidental concurrent
# modification of files by parallel build threads.
src = Schmant::SchmantFileSystems.getEntityForDirectory(
Java::JavaIo::
File.new("/home/me/myproject/src"),
true)
# Create a task executor that, by default, will use two build threads, unless
# the noOfBuildThreads property is set to another value.
te = Schmant::
TaskExecutor.new.
setNumberOfThreads($props.getIntValue("noOfBuildThreads", 2)).
start
begin
# A task for compiling all source files
#
TaskExecutor.add returns a
TaskDependency object for the added task.
javacDep = te.add(
Schmant::Jdk6JavacTF.new.
addSource(src).
addClasspathEntries(depjars).
setTarget(ctarget))
# A task for copying all non-Java files from the source hierarchy to the
# target hierarchy.
copyDep = te.add(
Schmant::TreeCopyTF.new.
# Create a view of the source hierarchy that hides all .java files.
setSource(
src.newView(
Schmant::
EFileNameExtensionFilter.new("java").not)).
setTarget(ctarget))
# A timestamp for the built archive
# SimpleDateFormat and Date are not included in the Schmant module, so we have
# to access them through the Java module instead.
ts = Java::JavaText::SimpleDateFormat.new("yyyyMMddHHmm").
format(Java::JavaUtil::
Date.new)
# Build the Jar file. Put it in /home/me/myproject
# The Jar build task depends on both the compiling and the copying tasks.
te.add(
Schmant::JarTF.new.
addSource(ctarget).
setTarget(
Java::JavaIo::
File.new("/home/me/myproject/myproject" + ts + ".jar")),
# Use an array for the two dependencies
[javacDep, copyDep])
# Wait for all tasks to complete
te.waitFor
ensure
te.shutdown
end
# A temporary directory for the compiled classes. This, along with all of its
# contents, will be automatically deleted when Schmant exits (unless the -k
# flag is used).
ctarget =
TempFileUtil.createTempDir()
# The lib directory that contains Jar files that the code to compile uses.
libDir =
SchmantFileSystems.getEntityForDirectory(
File("/home/me/myproject/lib"), True)
# Get all jar files from the lib directory. The jar files are returned as a
#
Set of EntityFS
EFile:s
depjars =
Directories.getAllFilesMatching(libDir, "*.jar")
# Add a dependency from the optlib directory. This is a Java
File
depjars.add(
File("/home/me/myproject/optlib/opt.jar"))
# Create a read only, locking
Directory object for the source directory.
# A locking file system eliminates the risk of accidental concurrent
# modification of files by parallel build threads.
src =
SchmantFileSystems.getEntityForDirectory(
File("/home/me/myproject/src"), \
True)
# Create a task executor that, by default, will use two build threads, unless
# the noOfBuildThreads property is set to another value.
te =
TaskExecutor(). \
setNumberOfThreads(props.getIntValue("noOfBuildThreads", 2)). \
start()
try:
# A task for compiling all source files
#
TaskExecutor.add returns a
TaskDependency object for the added task.
javacDep = te.add(
Jdk6JavacTF(). \
addSource(src). \
addClasspathEntries(depjars). \
setTarget(ctarget))
# A task for copying all non-Java files from the source hierarchy to the
# target hierarchy.
#
# Create a view of the source hierarchy that hides all .java files.
copyDep = te.add(
TreeCopyTF(). \
setSource(
src.newView(
EFileNameExtensionFilter("java").not())). \
setTarget(ctarget))
# A timestamp for the built archive
#
#
SimpleDateFormat is not automatically imported by the preparation
# script.
from java.text import SimpleDateFormat
timestamp =
SimpleDateFormat("yyyyMMddHHmm"). \
format(
Date())
# Build the Jar file. Put it in /home/me/myproject
# The Jar build task depends on both the compiling and the copying
# tasks.
#
# Use a list for the two dependencies
te.add(
JarTF(). \
addSource(ctarget). \
setTarget(
File("/home/me/myproject/myproject" + timestamp + ".jar")), \
[javacDep, copyDep])
# Wait for all tasks to complete
te.waitFor()
finally:
te.shutdown()