// enableTaskPackage net.findbugs
// The net.findbugs task package is enabled in the script manifest above. The
// task package has to be enabled before the script is loaded so that the
// classes in the task package are available to be imported below.
import java.io.File
import java.text.SimpleDateFormat
import java.util.Date
import org.entityfs.util.Directories
import org.schmant.support.io.TempFileUtil
import org.schmant.support.entityfs.SchmantFileSystems
import org.schmant.task.findbugs.*
import org.schmant.task.jdk.jar.JarTF
import org.schmant.task.jdk.javac.jdk6.Jdk6JavacTF
// Compile files from the directory /home/me/myproject/src and put the resulting
// class files in a temporary directory. The source files have compilation
// dependencies to all Jar files in /home/me/myproject/lib and to the Jar file
// /home/me/myproject/optlib/opt.jar
// A temporary java.io.File 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()
// This is the lib directory expressed as a (read only) EntityFS
Directory.
// By using a
Directory, the script can use the utility methods of
//
Directories to extract the files it wants. See below.
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"))
// Compile the Java source files.
new
Jdk6JavacTF().
addSource(new
File("/home/me/myproject/src")).
addClasspathEntries(depjars).
setTarget(ctarget).run()
// A timestamp for the built archive
def timestamp = new
SimpleDateFormat("yyyyMMddHHmm").
format(new
Date())
// Build the Jar file. Put it in /home/me/myproject
new
JarTF().
addSource(ctarget).
setTarget(new
File("/home/me/myproject/myproject" + timestamp + ".jar")).
run()
// Run Findbugs.
new
ExtFindbugsTF().
// If the findbugsExecutable property is not set, the task looks for the
// findbugs executable by checking if the FINDBUGS_HOME environment variable
// is set. If not, it searches for findbugs in the directories referenced by
// the PATH environment variable.
// setFindbugsExecutable("c:\\Java\\findbugs\\bin\\findbugs.bat").
//
// Add classpath dependencies that should not be analyzed
addAuxClasspathEntries(depjars).
// Add all source files
addSourceCodeContainer(new
File("/home/me/myproject/src")).
// The compiled classes are located under the directory ctarget (and
// subdirectories)
addSource(ctarget).
setFindbugsReportFormat(
FindbugsReportFormat.HTML).
setTarget(
new
File("/home/me/myproject/myproject" + timestamp + ".html")).run()
// Compile files from the directory /home/me/myproject/src and put the resulting
// class files in a temporary directory. The source files have compilation
// dependencies to all Jar files in /home/me/myproject/lib and to the Jar file
// /home/me/myproject/optlib/opt.jar
// A temporary java.io.File directory for the compiled classes. This, along with
// all of its contents, will be automatically deleted when Schmant exits (unless
// the -k flag was used when Schmant was launched).
ctarget =
TempFileUtil.createTempDir();
// This is the lib directory expressed as a (read only) EntityFS
Directory.
// By using a
Directory, the script can use the utility methods of
//
Directories to extract the files it wants. See below.
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"));
// Compile the Java source files.
new
Jdk6JavacTF().
addSource(new
File("/home/me/myproject/src")).
addClasspathEntries(depjars).
setTarget(ctarget).run();
// A timestamp for the built archive
// java.text.SimpleDateFormat must be fully qualified since the java.text
// package classes are not automatically imported by Schmant. The "Packages"
// prefix is for telling JavaScript that it is a Java package. It is required
// sometimes. See the chapter on script language support for more information.
timestamp = new Packages.java.text.SimpleDateFormat("yyyyMMddHHmm").
format(new
Date());
// Build the Jar file. Put it in /home/me/myproject
new
JarTF().
addSource(ctarget).
setTarget(new
File("/home/me/myproject/myproject" + timestamp + ".jar")).
run();
enableTaskPackage("net.findbugs");
// Run Findbugs.
new
ExtFindbugsTF().
// If the findbugsExecutable property is not set, the task looks for the
// findbugs executable by checking if the FINDBUGS_HOME environment variable
// is set. If not, it searches for findbugs in the directories referenced by
// the PATH environment variable.
// setFindbugsExecutable("c:\\Java\\findbugs\\bin\\findbugs.bat").
//
// Add classpath dependencies that should not be analyzed
addAuxClasspathEntries(depjars).
// Add all source files
addSourceCodeContainer(new
File("/home/me/myproject/src")).
// The compiled classes are located under the directory ctarget (and
// subdirectories)
addSource(ctarget).
setFindbugsReportFormat(
FindbugsReportFormat.HTML).
setTarget(
new
File("/home/me/myproject/myproject" + timestamp + ".html")).run();
# Compile files from the directory /home/me/myproject/src and put the resulting
# class files in a temporary directory. The source files have compilation
# dependencies to all Jar files in /home/me/myproject/lib and to the Jar file
# /home/me/myproject/optlib/opt.jar
# A temporary java.io.File directory for the compiled classes. This, along with
# all of its contents, will be automatically deleted when Schmant exits (unless
# the -k flag was used when Schmant was launched).
ctarget = Schmant::
TempFileUtil.createTempDir
# This is the lib directory expressed as a (read only) EntityFS
Directory.
# By using a
Directory, the script can use the utility methods of
#
Directories to extract the files it wants. See below.
#
#
File is not included in the Java module, so we have to access it through the
# Java module instead.
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"))
# Compile the Java source files.
Schmant::Jdk6JavacTF.new.
addSource(Java::JavaIo::
File.new("/home/me/myproject/src")).
addClasspathEntries(depjars).
setTarget(ctarget).run
# A timestamp for the built archive
timestamp = Java::JavaText::SimpleDateFormat.new("yyyyMMddHHmm").
format(Java::JavaUtil::
Date.new)
# Build the Jar file. Put it in /home/me/myproject
Schmant::JarTF.new.
addSource(ctarget).
setTarget(
Java::JavaIo::
File.new("/home/me/myproject/myproject" + timestamp + ".jar")).
run
enableTaskPackage "net.findbugs"
# Run Findbugs.
Schmant::ExtFindbugsTF.new.
# If the findbugsExecutable property is not set, the task looks for the
# findbugs executable by checking if the FINDBUGS_HOME environment variable
# is set. If not, it searches for findbugs in the directories referenced by
# the PATH environment variable.
# setFindbugsExecutable("c:\\Java\\findbugs\\bin\\findbugs.bat").
#
# Add classpath dependencies that should not be analyzed
addAuxClasspathEntries(depjars).
# Add all source files
addSourceCodeContainer(Java::JavaIo::
File.new("/home/me/myproject/src")).
# The compiled classes are located under the directory ctarget (and
# subdirectories)
addSource(ctarget).
setFindbugsReportFormat(Schmant::
FindbugsReportFormat::HTML).
setTarget(
Java::JavaIo::
File.new("/home/me/myproject/myproject" + timestamp + ".html")).
run
# Compile files from the directory /home/me/myproject/src and put the resulting
# class files in a temporary directory. The source files have compilation
# dependencies to all Jar files in /home/me/myproject/lib and to the Jar file
# /home/me/myproject/optlib/opt.jar
# A temporary java.io.File directory for the compiled classes. This, along with
# all of its contents, will be automatically deleted when Schmant exits (unless
# the -k flag was used when Schmant was launched).
ctarget =
TempFileUtil.createTempDir()
# This is the lib directory expressed as a (read only) EntityFS
Directory.
# By using a
Directory, the script can use the utility methods of
#
Directories to extract the files it wants. See below.
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"))
# Compile the Java source files.
Jdk6JavacTF(). \
addSource(
File("/home/me/myproject/src")). \
addClasspathEntries(depjars). \
setTarget(ctarget).run()
# 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
JarTF(). \
addSource(ctarget). \
setTarget(
File("/home/me/myproject/myproject" + timestamp + ".jar")). \
run()
enableTaskPackage("net.findbugs")
# Run Findbugs.
#
# If the findbugsExecutable property is not set, the task looks for the
# findbugs executable by checking if the FINDBUGS_HOME environment variable is
# set. If not, it searches for findbugs in the directories referenced by the
# PATH environment variable.
#
# The compiled classes are located under the directory ctarget (and
# subdirectories)
ExtFindbugsTF(). \
addAuxClasspathEntries(depjars). \
addSourceCodeContainer(
File("/home/me/myproject/src")). \
addSource(ctarget). \
setFindbugsReportFormat(
FindbugsReportFormat.HTML). \
setTarget( \
File("/home/me/myproject/myproject" + timestamp + ".html")).run()