class CompileJavaCode(JavaArtifact): def __init__ (self, name="lib", destination = 'lib', classpath = [], dependencies=[]): assert destination m = re.compile(r"[\*\[\]]").search(name) if m: self.fmask = name[m.start():len(name)] name = name[0:m.start()] else: self.fmask = "*/*.java" JavaArtifact.__init__(self, name, classpath, dependencies) self.destination = PermanentFileArtifact(destination) self.classpath.append(destination) def build(self): destination = self.destination.fullpath() source = self.fullpath() # collect java files if the source is directory if os.path.isdir(source): sources = " ".join(self.collect_sources(source)) if len(sources) == 0: raise BaseException("No Java source files found in '%s'", source) else: sources = source # form command line and run it cmd = self.form_cmd('javac') + " -d " + destination + " " + sources ShellScriptHelper.run(cmd) def collect_sources(self, path): p = os.path.join(path, self.fmask) return glob.glob(p) def what_it_does(self): return "Compile Java code located in '%s' into '%s' directory." % (self.name, self.destination.name)