Author: tchemit Date: 2008-10-15 13:46:48 +0000 (Wed, 15 Oct 2008) New Revision: 914 Modified: lutinjaxx/trunk/maven-jaxx-plugin/src/main/java/org/codelutin/jaxx/JaxxGeneratorMojo.java Log: skip goal for non java capable project Modified: lutinjaxx/trunk/maven-jaxx-plugin/src/main/java/org/codelutin/jaxx/JaxxGeneratorMojo.java =================================================================== --- lutinjaxx/trunk/maven-jaxx-plugin/src/main/java/org/codelutin/jaxx/JaxxGeneratorMojo.java 2008-10-15 13:46:23 UTC (rev 913) +++ lutinjaxx/trunk/maven-jaxx-plugin/src/main/java/org/codelutin/jaxx/JaxxGeneratorMojo.java 2008-10-15 13:46:48 UTC (rev 914) @@ -149,10 +149,21 @@ protected CompilerOptions options; - protected MirroredFileUpdater updater ; + protected MirroredFileUpdater updater; + protected boolean skip = true; + protected void init() { + if (project!=null && ("pom".equals(project.getPackaging()) || "site".equals(project.getPackaging()))) { + // nothing to be done for this type of packaging + skip = true; + getLog().info("skip generate goal for packaging " + project.getPackaging()); + return; + } + + skip=false; + if (!outResource.exists()) { outResource.mkdirs(); } @@ -182,7 +193,7 @@ } else { // filter files List<String> listFiles = new ArrayList<String>(); - + for (String file : files) { if (updater.isFileUpToDate(new File(src, file))) { if (verbose) { @@ -207,16 +218,6 @@ } - protected void doExecute() throws Exception { - - // force compiler init from here, not in a static block - TagManager.reset(verbose); - - if (!JAXXCompiler.compile(src, files, options)) { - throw new MojoFailureException("Aborting due to errors reported by jaxxc"); - } - } - public CompilerOptions toCompilerOptions() { CompilerOptions result = new CompilerOptions(); result.setClassPath(src.getPath()); @@ -233,41 +234,17 @@ return result; } - protected void printInit() { - getLog().info(options.toString()); - getLog().info("includes : " + Arrays.toString(includes)); - for (String file : files) { - getLog().info("will generate "+file); - } + public void execute() throws MojoExecutionException, MojoFailureException { - ClassLoader cl = Thread.currentThread().getContextClassLoader(); - getLog().info(cl.toString()); - if (cl.getClass().getSimpleName().equals("RealmClassLoader")) { - try { - java.lang.reflect.Method m = cl.getClass().getDeclaredMethod("getURLs"); - m.setAccessible(true); - URL[] urls = (URL[]) m.invoke(cl); + init(); - for (URL url : urls) { - getLog().info("url in class loader " + url); - } - } catch (Exception e) { - getLog().warn("??? : " + e.getMessage(), e); + if (skip) { + if (verbose) { + getLog().info("jaxx - skip!"); } + return; } - - //fixme should remove this silly test when we will make real maven plugin tests :) - if (getPluginContext() != null) { - for (Object e : getPluginContext().keySet()) { - getLog().info("pluginContext " + e + " : " + getPluginContext().get(e)); - } - } - } - - public void execute() throws MojoExecutionException, MojoFailureException { - - init(); - + if (files.length == 0) { getLog().info("jaxx - no jaxx file to treate. "); return; @@ -277,8 +254,13 @@ try { - doExecute(); + // force compiler init from here, not in a static block + TagManager.reset(verbose); + if (!JAXXCompiler.compile(src, files, options)) { + throw new MojoFailureException("Aborting due to errors reported by jaxxc"); + } + } catch (Exception e) { getLog().error(e); Throwable e2 = e; @@ -341,6 +323,37 @@ return loader; } + protected void printInit() { + getLog().info(options.toString()); + getLog().info("includes : " + Arrays.toString(includes)); + for (String file : files) { + getLog().info("will generate " + file); + } + + ClassLoader cl = Thread.currentThread().getContextClassLoader(); + getLog().info(cl.toString()); + if (cl.getClass().getSimpleName().equals("RealmClassLoader")) { + try { + java.lang.reflect.Method m = cl.getClass().getDeclaredMethod("getURLs"); + m.setAccessible(true); + URL[] urls = (URL[]) m.invoke(cl); + + for (URL url : urls) { + getLog().info("url in class loader " + url); + } + } catch (Exception e) { + getLog().warn("??? : " + e.getMessage(), e); + } + } + + //fixme should remove this silly test when we will make real maven plugin tests :) + if (getPluginContext() != null) { + for (Object e : getPluginContext().keySet()) { + getLog().info("pluginContext " + e + " : " + getPluginContext().get(e)); + } + } + } + public File getOutJava() { return outJava; }