Author: tom.baeyens(a)jboss.com
Date: 2009-10-31 10:28:11 -0400 (Sat, 31 Oct 2009)
New Revision: 5869
Modified:
projects/bbq/projects/bbq-core/src/org/bbq/Bbq.java
projects/bbq/projects/bbq-core/src/org/bbq/commands/ClassPath.java
projects/bbq/projects/bbq-core/src/org/bbq/commands/Exec.java
projects/bbq/projects/bbq-core/src/org/bbq/commands/Javac.java
projects/bbq/projects/bbq-core/src/org/bbq/system/FileScan.java
projects/bbq/projects/bbq-core/src/org/bbq/system/Os.java
projects/bbq/projects/bbq-core/src/org/bbq/system/Repository.java
projects/bbq/projects/bbq-test-project/build/Build.java
Log:
backup commit
Modified: projects/bbq/projects/bbq-core/src/org/bbq/Bbq.java
===================================================================
--- projects/bbq/projects/bbq-core/src/org/bbq/Bbq.java 2009-10-31 12:00:06 UTC (rev
5868)
+++ projects/bbq/projects/bbq-core/src/org/bbq/Bbq.java 2009-10-31 14:28:11 UTC (rev
5869)
@@ -39,7 +39,6 @@
public static final Properties properties = new Properties();
public static void main(String[] args) {
-
// initialize default properties
properties.setProperty("build.src.dir", "build");
properties.setProperty("build.classes.dir",
"gen/build-classes");
@@ -49,12 +48,22 @@
String buildSrcDir = properties.getProperty("build.src.dir");
String buildClassesDir = properties.getProperty("build.classes.dir");
- String buildClasspath = System.getProperty("java.class.path");
+ String buildClassPath = System.getProperty("java.class.path");
+
+ File buildSrcFile = new File(buildSrcDir);
+ if (!buildSrcFile.exists()) {
+ Console.log("no build source dir: "+buildSrcFile.getAbsolutePath()+"
doesn't exist");
+ return;
+ }
+ if (buildSrcFile.isFile()) {
+ Console.log("no build source dir: "+buildSrcFile.getAbsolutePath()+"
is a file");
+ return;
+ }
new Javac()
.srcDir(buildSrcDir)
.destDir(buildClassesDir)
- .classPath(buildClasspath)
+ .classPath(buildClassPath)
.execute();
try {
Modified: projects/bbq/projects/bbq-core/src/org/bbq/commands/ClassPath.java
===================================================================
--- projects/bbq/projects/bbq-core/src/org/bbq/commands/ClassPath.java 2009-10-31 12:00:06
UTC (rev 5868)
+++ projects/bbq/projects/bbq-core/src/org/bbq/commands/ClassPath.java 2009-10-31 14:28:11
UTC (rev 5869)
@@ -48,8 +48,25 @@
return this;
}
- public ClassPath execute() {
-
+ public ClassPath add(ClassPath other) {
+ elements.addAll(other.elements);
return this;
}
+
+ public boolean isEmpty() {
+ return elements.isEmpty();
+ }
+
+ public String toString() {
+ return toString(";");
+ }
+ public String toString(String separator) {
+ StringBuilder stringBuilder = new StringBuilder();
+ for (int i=0; i<(elements.size()-1); i++) {
+ stringBuilder.append(elements.get(i));
+ stringBuilder.append(separator);
+ }
+ stringBuilder.append(elements.size()-1);
+ return stringBuilder.toString();
+ }
}
Modified: projects/bbq/projects/bbq-core/src/org/bbq/commands/Exec.java
===================================================================
--- projects/bbq/projects/bbq-core/src/org/bbq/commands/Exec.java 2009-10-31 12:00:06 UTC
(rev 5868)
+++ projects/bbq/projects/bbq-core/src/org/bbq/commands/Exec.java 2009-10-31 14:28:11 UTC
(rev 5869)
@@ -35,6 +35,7 @@
public class Exec {
List<String> cmd;
+ String description;
public Exec(List<String> cmd) {
this.cmd = cmd;
@@ -42,9 +43,12 @@
public void execute() {
try {
- String msg = "exec";
- for (String cmdPart: cmd) {
- msg += " "+cmdPart;
+ String msg = description;
+ if (msg==null) {
+ msg = "exec ";
+ for (String cmdPart: cmd) {
+ msg += " "+cmdPart;
+ }
}
Console.log(msg);
@@ -54,11 +58,16 @@
BufferedReader bufferedReader = new BufferedReader(new
InputStreamReader(process.getErrorStream()));
for (String line = bufferedReader.readLine(); line!=null; line =
bufferedReader.readLine()) {
- Console.log(" |"+line);
+ Console.log(" |"+line);
}
} catch (Exception e) {
throw new BbqException("couldn't exec "+cmd, e);
}
}
+
+ public Exec description(String description) {
+ this.description = description;
+ return this;
+ }
}
Modified: projects/bbq/projects/bbq-core/src/org/bbq/commands/Javac.java
===================================================================
--- projects/bbq/projects/bbq-core/src/org/bbq/commands/Javac.java 2009-10-31 12:00:06 UTC
(rev 5868)
+++ projects/bbq/projects/bbq-core/src/org/bbq/commands/Javac.java 2009-10-31 14:28:11 UTC
(rev 5869)
@@ -36,8 +36,8 @@
FileList sourceFiles = new FileList();
boolean verbose;
- String destDir;
- String classPath;
+ String destDir = "gen/classes";
+ ClassPath classPath = new ClassPath();
public Javac srcDir(String srcDir) {
FileList sourceFiles = new FileScan(srcDir)
@@ -61,10 +61,15 @@
}
public Javac classPath(String classPath) {
- this.classPath = classPath;
+ this.classPath.add(classPath);
return this;
}
+ public Javac classPath(ClassPath classPath) {
+ this.classPath.add(classPath);
+ return this;
+ }
+
public Javac verbose() {
this.verbose = true;
return this;
@@ -80,23 +85,25 @@
cmd.add(Java.JAVA_HOME+Os.FILE_SEPARATOR+"bin"+Os.FILE_SEPARATOR+"javac");
cmd.add("-d");
cmd.add(destDir);
- if (classPath!=null) {
+ String description = "javac -d "+destDir;
+ if (!classPath.isEmpty()) {
cmd.add("-classpath");
- cmd.add(classPath);
+ cmd.add(classPath.toString());
+ for (String classPathElement: classPath.elements) {
+ description += Os.LINE_SEPARATOR+" classpath-element:
"+classPathElement;
+ }
}
if (verbose) {
cmd.add("-verbose");
}
for (String fileName: sourceFiles.list()) {
cmd.add(fileName);
+ description += Os.LINE_SEPARATOR+" source-file: "+fileName;
}
// execute the compile command
new Exec(cmd)
+ .description(description)
.execute();
}
-
- public ClassPath classPath(ClassPath classPath) {
- return null;
- }
}
Modified: projects/bbq/projects/bbq-core/src/org/bbq/system/FileScan.java
===================================================================
--- projects/bbq/projects/bbq-core/src/org/bbq/system/FileScan.java 2009-10-31 12:00:06
UTC (rev 5868)
+++ projects/bbq/projects/bbq-core/src/org/bbq/system/FileScan.java 2009-10-31 14:28:11
UTC (rev 5869)
@@ -46,12 +46,14 @@
private void scan(String dir, FileList fileList) {
File dirFile = new File(dir);
- for (File child: dirFile.listFiles()) {
- String childPath = ("".equals(dir) ? child.getName() :
dir+"/"+child.getName());
- if (child.isDirectory()) {
- scan(childPath, fileList);
- } else if (passesFilters(childPath, child)) {
- fileList.add(childPath);
+ if (dirFile.exists()) {
+ for (File child: dirFile.listFiles()) {
+ String childPath = ("".equals(dir) ? child.getName() :
dir+"/"+child.getName());
+ if (child.isDirectory()) {
+ scan(childPath, fileList);
+ } else if (passesFilters(childPath, child)) {
+ fileList.add(childPath);
+ }
}
}
}
Modified: projects/bbq/projects/bbq-core/src/org/bbq/system/Os.java
===================================================================
--- projects/bbq/projects/bbq-core/src/org/bbq/system/Os.java 2009-10-31 12:00:06 UTC (rev
5868)
+++ projects/bbq/projects/bbq-core/src/org/bbq/system/Os.java 2009-10-31 14:28:11 UTC (rev
5869)
@@ -33,6 +33,7 @@
public static final String TYPE = getType();
public static final String FILE_SEPARATOR =
System.getProperty("file.separator");
+ public static final String LINE_SEPARATOR =
System.getProperty("line.separator");
private static String getType() {
String name = System.getProperty("os.name");
Modified: projects/bbq/projects/bbq-core/src/org/bbq/system/Repository.java
===================================================================
--- projects/bbq/projects/bbq-core/src/org/bbq/system/Repository.java 2009-10-31 12:00:06
UTC (rev 5868)
+++ projects/bbq/projects/bbq-core/src/org/bbq/system/Repository.java 2009-10-31 14:28:11
UTC (rev 5869)
@@ -37,10 +37,12 @@
*/
public class Repository {
+ String name;
String remoteUrl;
String localRepositoryPath;
- public Repository(String remoteUrl, String name) {
+ public Repository(String name, String remoteUrl) {
+ this.name = name;
this.remoteUrl = remoteUrl;
this.localRepositoryPath =
Bbq.properties.getProperty("local.repo.dir")+"/"+name;
}
@@ -50,7 +52,7 @@
File artifactFile = new File(absoluteArtifactPath);
if (!artifactFile.exists()) {
- Console.print("downloading repo artifact "+path);
+ Console.log("downloading "+path+" from "+name);
// first make sure the directory exists
int index = absoluteArtifactPath.lastIndexOf('/');
@@ -74,13 +76,20 @@
protected void pump(URL artifactUrl, OutputStream out) throws Exception {
int bufferSize = 1024*10; // 10K
int total = 0;
+ int dotCount = 0;
byte[] buffer = new byte[bufferSize];
InputStream in = null;
try {
in = artifactUrl.openStream();
int bytesRead = in.read( buffer );
while ( bytesRead != -1 ) {
- Console.print(".");
+ if (dotCount<80) {
+ Console.print(".");
+ dotCount++;
+ } else {
+ dotCount = 0;
+ Console.log(" "+(total/1024)+" KBytes");
+ }
out.write( buffer, 0, bytesRead );
total += bytesRead;
bytesRead = in.read( buffer );
Modified: projects/bbq/projects/bbq-test-project/build/Build.java
===================================================================
--- projects/bbq/projects/bbq-test-project/build/Build.java 2009-10-31 12:00:06 UTC (rev
5868)
+++ projects/bbq/projects/bbq-test-project/build/Build.java 2009-10-31 14:28:11 UTC (rev
5869)
@@ -30,16 +30,23 @@
*/
public class Build {
- static Repository jbossRepository = new
Repository("http://repository.jboss.com/maven2/", "jboss");
+ static Repository jbossRepository = new Repository("jboss",
"http://repository.jboss.com/maven2/");
public static void compile() {
ClassPath classPath = new ClassPath()
- .add(jbossRepository,
"org/hibernate/hibernate-core/3.3.2.GA/hibernate-core-3.3.2.GA.jar");
+ .add(jbossRepository,
"org/hibernate/hibernate-core/3.3.2.GA/hibernate-core-3.3.2.GA.jar")
+ .add("../some/relative/path;/some/absolute/path");
new Javac()
.srcDir("src")
- .destDir("build/gen/classes")
+ .destDir("gen/classes")
.classPath(classPath)
.execute();
}
+
+ public static void jar() {
+ }
+
+ public static void publish() {
+ }
}