[Buix-commits] r1360 - in guix/trunk/guix-maven-plugin/src/main: java/org/nuiton/guix resources
Author: kmorin Date: 2009-04-27 16:07:40 +0000 (Mon, 27 Apr 2009) New Revision: 1360 Added: guix/trunk/guix-maven-plugin/src/main/resources/log4j.properties Modified: guix/trunk/guix-maven-plugin/src/main/java/org/nuiton/guix/GuixMojo.java Log: - Ajout de la config de log4j - Config des dossiers des fichiers Guix et du dossier de destination dans le pom.xml Modified: guix/trunk/guix-maven-plugin/src/main/java/org/nuiton/guix/GuixMojo.java =================================================================== --- guix/trunk/guix-maven-plugin/src/main/java/org/nuiton/guix/GuixMojo.java 2009-04-27 16:06:15 UTC (rev 1359) +++ guix/trunk/guix-maven-plugin/src/main/java/org/nuiton/guix/GuixMojo.java 2009-04-27 16:07:40 UTC (rev 1360) @@ -1,20 +1,67 @@ package org.nuiton.guix; +import java.io.File; +import java.util.ArrayList; +import org.apache.log4j.Logger; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; /** + * Launches the program * * @author morin * @goal testMojo */ public class GuixMojo extends AbstractMojo { - + /** + * Directory of the files to compile. + * @parameter expression="${guixFilesDir}" + * @required + */ + private String guixFilesDir; + + /** + * Directory of the generated files. + * @parameter expression="${generatedFilesDestination}" default-value="generatedFiles" + */ + private String targetDirectory; + @Override public void execute() throws MojoExecutionException, MojoFailureException { GuixInitializer.initialize(); - GuixLauncher gcl = new GuixLauncher(); + File guixFilesDir = new File(this.guixFilesDir); + File targetDirectory = new File(this.targetDirectory); + + if(!targetDirectory.exists()) + targetDirectory.mkdirs(); + + if(guixFilesDir.exists() && guixFilesDir.isDirectory()) { + ArrayList<File> guixFiles = goDeeperInto(guixFilesDir); + + GuixLauncher gcl = new GuixLauncher(guixFiles.toArray(new File[guixFiles.size()]),targetDirectory); + boolean result = gcl.compile(); + + if(result) + Logger.getLogger(GuixMojo.class).info("Compilation succeeded !"); + else + Logger.getLogger(GuixMojo.class).error("Compilation failed..."); + } } + + private ArrayList<File> goDeeperInto(File dir) { + Logger.getLogger(GuixMojo.class).debug("goind deeper into " + dir.getPath()); + ArrayList<File> result = new ArrayList<File>(); + for(File f : dir.listFiles()) { + if(f.isDirectory() && !f.isHidden()) { + result.addAll(goDeeperInto(f)); + } + else if(f.getName().endsWith(".guix")) { + Logger.getLogger(GuixMojo.class).debug("found " + f.getName()); + result.add(f); + } + } + return result; + } } Added: guix/trunk/guix-maven-plugin/src/main/resources/log4j.properties =================================================================== --- guix/trunk/guix-maven-plugin/src/main/resources/log4j.properties (rev 0) +++ guix/trunk/guix-maven-plugin/src/main/resources/log4j.properties 2009-04-27 16:07:40 UTC (rev 1360) @@ -0,0 +1,9 @@ +# Global logging configuration +log4j.rootLogger=INFO, stdout +# Console output... +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=%5p [%F : %M] %m%n + +#log4j.logger.org.codelutin.i18n=ERROR +log4j.logger.org.nuiton.guix=DEBUG
participants (1)
-
kmorin@users.labs.libre-entreprise.org