Author: tom.baeyens(a)jboss.com
Date: 2009-10-31 07:33:22 -0400 (Sat, 31 Oct 2009)
New Revision: 5866
Added:
projects/bbq/projects/bbq-core/lib/junit-4.4.jar
projects/bbq/projects/bbq-core/src/org/bbq/commands/ClassPath.java
projects/bbq/projects/bbq-core/src/org/bbq/system/Repository.java
projects/bbq/projects/bbq-core/test/org/
projects/bbq/projects/bbq-core/test/org/bbq/
projects/bbq/projects/bbq-core/test/org/bbq/test/
projects/bbq/projects/bbq-test-project/build/Build.java
projects/bbq/projects/bbq-test-project/gen/
Removed:
projects/bbq/projects/bbq-test-project/build/src/
Modified:
projects/bbq/projects/bbq-core/src/org/bbq/Bbq.java
projects/bbq/projects/bbq-core/src/org/bbq/commands/Javac.java
projects/bbq/projects/bbq-core/src/org/bbq/system/Console.java
projects/bbq/projects/bbq-test-project/.classpath
Log:
backup commit
Added: projects/bbq/projects/bbq-core/lib/junit-4.4.jar
===================================================================
(Binary files differ)
Property changes on: projects/bbq/projects/bbq-core/lib/junit-4.4.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: projects/bbq/projects/bbq-core/src/org/bbq/Bbq.java
===================================================================
--- projects/bbq/projects/bbq-core/src/org/bbq/Bbq.java 2009-10-31 11:32:01 UTC (rev
5865)
+++ projects/bbq/projects/bbq-core/src/org/bbq/Bbq.java 2009-10-31 11:33:22 UTC (rev
5866)
@@ -25,9 +25,9 @@
import java.lang.reflect.Method;
import java.net.URL;
import java.net.URLClassLoader;
+import java.util.Properties;
import org.bbq.commands.Javac;
-import org.bbq.commands.MkDir;
import org.bbq.system.Console;
@@ -35,18 +35,30 @@
* @author Tom Baeyens
*/
public class Bbq {
+
+ 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");
+ properties.setProperty("local.repo.dir",
System.getProperty("user.home")+"/.bbq");
+ // optionally bbq.properties files could be read
+ // from ${user.home}/.bbq/bbq.properties and ./bbq.properties
+
+ String buildSrcDir = properties.getProperty("build.src.dir");
+ String buildClassesDir = properties.getProperty("build.classes.dir");
String buildClasspath = System.getProperty("java.class.path");
-
+
new Javac()
- .srcDir("build/src")
- .destDir("build/gen/build-classes")
+ .srcDir(buildSrcDir)
+ .destDir(buildClassesDir)
.classPath(buildClasspath)
.execute();
try {
- URL[] urls = {new File("build/gen/build-classes").toURL()};
+ URL[] urls = {new File(buildClassesDir).toURL()};
ClassLoader classLoader = new URLClassLoader(urls , Bbq.class.getClassLoader());
Class<?> buildClass = Class.forName("Build", true, classLoader);
for (String operation: args) {
Added: projects/bbq/projects/bbq-core/src/org/bbq/commands/ClassPath.java
===================================================================
--- projects/bbq/projects/bbq-core/src/org/bbq/commands/ClassPath.java
(rev 0)
+++ projects/bbq/projects/bbq-core/src/org/bbq/commands/ClassPath.java 2009-10-31 11:33:22
UTC (rev 5866)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.bbq.commands;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import org.bbq.system.Repository;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ClassPath {
+
+ List<String> elements = new ArrayList<String>();
+
+ public ClassPath add(Repository repository, String path) {
+ add(repository.getArtifactPath(path));
+ return this;
+ }
+
+ public ClassPath add(String path) {
+ StringTokenizer tokenizer = new StringTokenizer(path, ";");
+ while (tokenizer.hasMoreTokens()) {
+ elements.add(tokenizer.nextToken());
+ }
+ return this;
+ }
+
+ public ClassPath execute() {
+
+ return this;
+ }
+}
Property changes on: projects/bbq/projects/bbq-core/src/org/bbq/commands/ClassPath.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
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 11:32:01 UTC
(rev 5865)
+++ projects/bbq/projects/bbq-core/src/org/bbq/commands/Javac.java 2009-10-31 11:33:22 UTC
(rev 5866)
@@ -95,4 +95,8 @@
new Exec(cmd)
.execute();
}
+
+ public ClassPath classPath(ClassPath classPath) {
+ return null;
+ }
}
Modified: projects/bbq/projects/bbq-core/src/org/bbq/system/Console.java
===================================================================
--- projects/bbq/projects/bbq-core/src/org/bbq/system/Console.java 2009-10-31 11:32:01 UTC
(rev 5865)
+++ projects/bbq/projects/bbq-core/src/org/bbq/system/Console.java 2009-10-31 11:33:22 UTC
(rev 5866)
@@ -30,4 +30,8 @@
public static void log(String msg) {
System.err.println(msg);
}
+ public static void print(String msg) {
+ System.err.print(msg);
+ System.err.flush();
+ }
}
Added: projects/bbq/projects/bbq-core/src/org/bbq/system/Repository.java
===================================================================
--- projects/bbq/projects/bbq-core/src/org/bbq/system/Repository.java
(rev 0)
+++ projects/bbq/projects/bbq-core/src/org/bbq/system/Repository.java 2009-10-31 11:33:22
UTC (rev 5866)
@@ -0,0 +1,99 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.bbq.system;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URL;
+
+import org.bbq.Bbq;
+import org.bbq.BbqException;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class Repository {
+
+ String remoteUrl;
+ String localRepositoryPath;
+
+ public Repository(String remoteUrl, String name) {
+ this.remoteUrl = remoteUrl;
+ this.localRepositoryPath =
Bbq.properties.getProperty("local.repo.dir")+"/"+name;
+ }
+
+ public String getArtifactPath(String path) {
+ String absoluteArtifactPath = localRepositoryPath+"/"+path;
+
+ File artifactFile = new File(absoluteArtifactPath);
+ if (!artifactFile.exists()) {
+ Console.print("downloading repo artifact "+path);
+
+ // first make sure the directory exists
+ int index = absoluteArtifactPath.lastIndexOf('/');
+ String artifactDirPath = absoluteArtifactPath.substring(0, index);
+ File artifactDir = new File(artifactDirPath);
+ artifactDir.mkdirs();
+
+ // download the artifact
+ try {
+ FileOutputStream fileStream = new FileOutputStream(artifactFile);
+ URL artifactUrl = new URL(remoteUrl+"/"+path);
+ pump(artifactUrl, fileStream);
+ } catch (Exception e) {
+ throw new BbqException("couldn't fetch repo artifact "+path);
+ }
+ }
+
+ return absoluteArtifactPath;
+ }
+
+ protected void pump(URL artifactUrl, OutputStream out) throws Exception {
+ int bufferSize = 1024*10; // 10K
+ int total = 0;
+ byte[] buffer = new byte[bufferSize];
+ InputStream in = null;
+ try {
+ in = artifactUrl.openStream();
+ int bytesRead = in.read( buffer );
+ while ( bytesRead != -1 ) {
+ Console.print(".");
+ out.write( buffer, 0, bytesRead );
+ total += bytesRead;
+ bytesRead = in.read( buffer );
+ }
+ } finally {
+ Console.log("done");
+ if (in!=null) {
+ try {
+ in.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+}
Property changes on: projects/bbq/projects/bbq-core/src/org/bbq/system/Repository.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: projects/bbq/projects/bbq-test-project/.classpath
===================================================================
--- projects/bbq/projects/bbq-test-project/.classpath 2009-10-31 11:32:01 UTC (rev 5865)
+++ projects/bbq/projects/bbq-test-project/.classpath 2009-10-31 11:33:22 UTC (rev 5866)
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
- <classpathentry kind="src" output="build/gen/build-classes"
path="build/src"/>
+ <classpathentry kind="src" path="build"/>
<classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry combineaccessrules="false" kind="src"
path="/bbq-core"/>
- <classpathentry kind="output" path="build/gen/classes"/>
+ <classpathentry kind="output" path="gen/classes"/>
</classpath>
Copied: projects/bbq/projects/bbq-test-project/build/Build.java (from rev 5864,
projects/bbq/projects/bbq-test-project/build/src/Build.java)
===================================================================
--- projects/bbq/projects/bbq-test-project/build/Build.java (rev
0)
+++ projects/bbq/projects/bbq-test-project/build/Build.java 2009-10-31 11:33:22 UTC (rev
5866)
@@ -0,0 +1,45 @@
+import org.bbq.commands.ClassPath;
+import org.bbq.commands.Javac;
+import org.bbq.system.Repository;
+
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+/**
+ * @author Tom Baeyens
+ */
+public class Build {
+
+ static Repository jbossRepository = new
Repository("http://repository.jboss.com/maven2/", "jboss");
+
+ 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");
+
+ new Javac()
+ .srcDir("src")
+ .destDir("build/gen/classes")
+ .classPath(classPath)
+ .execute();
+ }
+}
Property changes on: projects/bbq/projects/bbq-test-project/build/Build.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain