Revision: 3902 http://vexi.svn.sourceforge.net/vexi/?rev=3902&view=rev Author: mkpg2 Date: 2010-09-16 01:31:04 +0000 (Thu, 16 Sep 2010)
Log Message: ----------- Generate jpp sources artifact (necessary for jsdoc). Modified Paths: -------------- trunk/org.vexi-build.jpp/meta/module.xml trunk/org.vexi-build.jpp/src/main/java/org/vexi/build/jpp/PreprocessorBuilder.java trunk/org.vexi-build.shared/meta/upstream.revisions Added Paths: ----------- trunk/org.vexi-build.jpp/src/main/java/org/vexi/build/jpp/build.xml Removed Paths: ------------- trunk/org.vexi-library.util/src_dev/ trunk/org.vexi-library.util/src_junit/ Modified: trunk/org.vexi-build.jpp/meta/module.xml =================================================================== --- trunk/org.vexi-build.jpp/meta/module.xml 2010-09-14 03:09:29 UTC (rev 3901) +++ trunk/org.vexi-build.jpp/meta/module.xml 2010-09-16 01:31:04 UTC (rev 3902) @@ -2,11 +2,12 @@ <using source="local" name="build.shared"/> <declare-builder class="org.vexi.build.jpp.PreprocessorBuilder" - input="jpp" output="java"/> + input="jpp" output="java,jpp.sources"/> <dependencies> <dependency source="system" name="jre" version="1.6"/> <dependency source="ebuild.org" name="api" /> + <dependency source="ebuild.org" name="lib.ant" /> <dependency source="ebuild.org" name="lib.util" /> <dependency source="local" name="library.util" /> <dependency source="local" name="library.testing" scope="test"/> Modified: trunk/org.vexi-build.jpp/src/main/java/org/vexi/build/jpp/PreprocessorBuilder.java =================================================================== --- trunk/org.vexi-build.jpp/src/main/java/org/vexi/build/jpp/PreprocessorBuilder.java 2010-09-14 03:09:29 UTC (rev 3901) +++ trunk/org.vexi-build.jpp/src/main/java/org/vexi/build/jpp/PreprocessorBuilder.java 2010-09-16 01:31:04 UTC (rev 3902) @@ -6,8 +6,17 @@ import java.io.IOException; import java.io.Reader; import java.io.Writer; +import java.util.ArrayList; +import java.util.List; import java.util.Map; +import org.apache.tools.ant.Project; +import org.apache.tools.ant.types.FileSet; +import org.apache.tools.ant.types.Path; +import org.apache.tools.ant.types.selectors.FilenameSelector; + +import ebuild.ant.AntStuff; +import ebuild.ant.AntStuff.Execution; import ebuild.api.IBuilderArgument; import ebuild.api.IModuleBuildProject; import ebuild.api.log.ILogger; @@ -38,51 +47,101 @@ } return m; } + + public void build(IBuilderArgument argument) throws BuildPluginException{ + try{ + preprocess(argument); + zipsources(argument); + }catch(Exception e){ + throw new BuildPluginException(e); + } + } - public void build(IBuilderArgument argument) throws BuildPluginException{ + public void preprocess(IBuilderArgument argument) throws Exception{ final ILogger logger = argument.getLogger(); - try{ - IModuleBuildProject module = argument.getModuleBuildProject(); - IPropertyMap props = argument.getPropertyMap(); - String definesStr = props.getString("defines","{}"); - Map<String,Object> defines = parseDefines(definesStr); - defines.put("MODULE_VERSION", module.getVersionString()); - //Scope s = mode==BuildMode.eclipse?Scope.TEST:Scope.MAIN; - - if(argument.isFirstCall()){ - logger.log("defines:"); - for(String k: defines.keySet()){ - Object v = defines.get(k); - logger.log(" "+k+" : "+v); - } + IModuleBuildProject module = argument.getModuleBuildProject(); + IPropertyMap props = argument.getPropertyMap(); + String definesStr = props.getString("defines","{}"); + Map<String,Object> defines = parseDefines(definesStr); + defines.put("MODULE_VERSION", module.getVersionString()); + //Scope s = mode==BuildMode.eclipse?Scope.TEST:Scope.MAIN; + + if(argument.isFirstCall()){ + logger.log("defines:"); + for(String k: defines.keySet()){ + Object v = defines.get(k); + logger.log(" "+k+" : "+v); } - - final File genDir = argument.getOutputDir("java"); - for(final File srcDir: argument.getInputDirs("jpp")){ - final Preprocessor preprocessor = new Preprocessor(new SourcePath(srcDir), defines); - new FileUtil.Traversal(){ - public void onFile(File in) throws Exception { - if(in.getName().endsWith(".jpp")){ - String relativeIn = FileUtil.relativePath(srcDir, in); - String relativeOut = FileUtil.replaceSuffix(relativeIn, "java"); - File out = new File(genDir, relativeOut); + } - logger.log(" .jpp " + in.getCanonicalPath()); - if (!out.exists() || (out.lastModified() > in.lastModified())){ - logger.log("-> .java " + out.getCanonicalPath()); - out.getParentFile().mkdirs(); - Writer writer = new FileWriter(out); - preprocessor.preprocess(relativeIn, writer); - writer.close(); - } + final File genDir = argument.getOutputDir("java"); + for(final File srcDir: argument.getInputDirs("jpp")){ + final Preprocessor preprocessor = new Preprocessor(new SourcePath(srcDir), defines); + new FileUtil.Traversal(){ + public void onFile(File in) throws Exception { + if(in.getName().endsWith(".jpp")){ + String relativeIn = FileUtil.relativePath(srcDir, in); + String relativeOut = FileUtil.replaceSuffix(relativeIn, "java"); + File out = new File(genDir, relativeOut); + + logger.log(" .jpp " + in.getCanonicalPath()); + if (!out.exists() || (out.lastModified() > in.lastModified())){ + logger.log("-> .java " + out.getCanonicalPath()); + out.getParentFile().mkdirs(); + Writer writer = new FileWriter(out); + preprocessor.preprocess(relativeIn, writer); + writer.close(); } } - }.go(srcDir); - } - - }catch(Exception e){ - throw new BuildPluginException(e); + } + }.go(srcDir); } } + + private List<String> sourcesList(IBuilderArgument argument){ + List<File> fs = argument.getInputDirs("jpp"); + List<String> r = new ArrayList(fs.size()); + for(File f: fs) r.add(f.getAbsolutePath()); + return r; + } + + private Path sourcesPath(Project p, List<String> sources, boolean negate){ + Path sourcePath = new Path(p); + FilenameSelector fns = new FilenameSelector(); + fns.setName("**/*.jpp"); + fns.setNegate(negate); + for(String s: sources){ + FileSet fs = new FileSet(); + fs.setDir(new File(s)); + fs.addFilename(fns); + sourcePath.addFileset(fs); + } + return sourcePath; + } + + + public void zipsources(IBuilderArgument argument) throws Exception{ + final ILogger logger = argument.getLogger(); + IModuleBuildProject module = argument.getModuleBuildProject(); + File targetSources = argument.getOutputDir("jpp.sources"); + + // inputs + List<String> sources = sourcesList(argument); + + Project p = new Project(); + + // inputs + Path sourcePath = sourcesPath(p, sources, false); + p.addReference("source.path", sourcePath); + + // outputs + String jarname = module.getName(); + targetSources.mkdirs(); + p.setUserProperty("target.sources", targetSources.getAbsolutePath()); + p.setUserProperty("jarname", jarname); + + Execution e = AntStuff.newExecution(p, logger, "build.xml", getClass()); + e.executeTarget("zip_sources"); + } } Added: trunk/org.vexi-build.jpp/src/main/java/org/vexi/build/jpp/build.xml =================================================================== --- trunk/org.vexi-build.jpp/src/main/java/org/vexi/build/jpp/build.xml (rev 0) +++ trunk/org.vexi-build.jpp/src/main/java/org/vexi/build/jpp/build.xml 2010-09-16 01:31:04 UTC (rev 3902) @@ -0,0 +1,8 @@ + +<project name="standard java"> + <target name="zip_sources"> + <zip destfile="${target.sources}/${jarname}-jppsources.zip"> + <path refid="source.path" /> + </zip> + </target> +</project> Property changes on: trunk/org.vexi-build.jpp/src/main/java/org/vexi/build/jpp/build.xml ___________________________________________________________________ Added: svn:mime-type + text/plain Modified: trunk/org.vexi-build.shared/meta/upstream.revisions =================================================================== --- trunk/org.vexi-build.shared/meta/upstream.revisions 2010-09-14 03:09:29 UTC (rev 3901) +++ trunk/org.vexi-build.shared/meta/upstream.revisions 2010-09-16 01:31:04 UTC (rev 3902) @@ -1 +1 @@ -{"https:\/\/svn.origo.ethz.ch\/ebuild":"67"} \ No newline at end of file +{"https:\/\/svn.origo.ethz.ch\/ebuild":"79"} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Start uncovering the many advantages of virtual appliances and start using them to simplify application deployment and accelerate your shift to cloud computing. http://p.sf.net/sfu/novell-sfdev2dev _______________________________________________ Vexi-svn mailing list Vexi-svn@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/vexi-svn