Author: tchemit Date: 2009-01-18 13:13:15 +0000 (Sun, 18 Jan 2009) New Revision: 1167 Modified: jaxx/trunk/maven-jaxx-plugin/src/main/java/org/codelutin/jaxx/JaxxGeneratorMojo.java Log: use requiresDependencyResolution javadoc annotation to resolved compile scope dependencies. Modified: jaxx/trunk/maven-jaxx-plugin/src/main/java/org/codelutin/jaxx/JaxxGeneratorMojo.java =================================================================== --- jaxx/trunk/maven-jaxx-plugin/src/main/java/org/codelutin/jaxx/JaxxGeneratorMojo.java 2009-01-13 16:23:43 UTC (rev 1166) +++ jaxx/trunk/maven-jaxx-plugin/src/main/java/org/codelutin/jaxx/JaxxGeneratorMojo.java 2009-01-18 13:13:15 UTC (rev 1167) @@ -26,24 +26,11 @@ import jaxx.runtime.JAXXContext; import jaxx.tags.TagManager; import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.DefaultArtifact; -import org.apache.maven.artifact.factory.ArtifactFactory; -import org.apache.maven.artifact.metadata.ArtifactMetadataSource; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.resolver.ArtifactCollector; -import org.apache.maven.artifact.resolver.ArtifactNotFoundException; -import org.apache.maven.artifact.resolver.ArtifactResolutionException; -import org.apache.maven.artifact.resolver.ArtifactResolutionResult; -import org.apache.maven.artifact.resolver.ArtifactResolver; -import org.apache.maven.artifact.resolver.DebugResolutionListener; -import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugin.logging.Log; import org.apache.maven.project.MavenProject; -import org.apache.maven.project.artifact.InvalidDependencyVersionException; -import org.codehaus.plexus.logging.console.ConsoleLogger; import org.codehaus.plexus.util.DirectoryScanner; import org.codelutin.util.FileUpdaterHelper; import org.codelutin.util.MirroredFileUpdater; @@ -65,36 +52,11 @@ * @author chemit * @goal generate * @phase process-sources + * @requiresDependencyResolution compile */ public class JaxxGeneratorMojo extends AbstractMojo { - /** - * Artifact Factory component. - * - * @component - */ - protected ArtifactFactory factory; - /** - * Artifact collector component. - * - * @component - */ - protected ArtifactCollector collector; /** - * Artifact resolver component. - * - * @component - */ - protected ArtifactResolver resolver; - - /** - * Artifact metadata source component. - * - * @component - */ - protected ArtifactMetadataSource artifactMetadataSource; - - /** * Dépendance du projet. * * @parameter default-value="${project}" @@ -104,25 +66,6 @@ protected MavenProject project; /** - * Local Repository. - * - * @parameter expression="${localRepository}" - * @required - * @readonly - */ - protected ArtifactRepository localRepository; - - - /** - * Remote repositories used for the project. - * - * @parameter expression="${project.remoteArtifactRepositories}" - * @required - * @readonly - */ - protected List remoteRepositories; - - /** * Le compilateur à utiliser (par défaut celui de Swing) * * @parameter expression="${jaxx.compilerFQN}" default-value="jaxx.compiler.SwingCompiler" @@ -435,7 +378,11 @@ return; } - doAction(); + try { + doAction(); + } finally { + System.gc(); + } } @@ -453,10 +400,6 @@ throw new MojoFailureException("Aborting due to errors reported by jaxxc"); } - /*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; @@ -496,27 +439,10 @@ } if (addProjectClassPath) { getLog().info("use project compile scope class-path"); - // add also all dependency of the project in compile scope - Set dependencyArtifacts = project.getDependencyArtifacts(); - if (dependencyArtifacts == null) { - // obtain artifacts - dependencyArtifacts = project.createArtifacts(factory, DefaultArtifact.SCOPE_COMPILE, null); - } - List listeners = new ArrayList(); - if (isVerbose()) { - listeners.add(new DebugResolutionListener(new ConsoleLogger(0, "jaxx"))); - } - // collects artifact best version - ArtifactResolutionResult resolved = collector.collect(dependencyArtifacts, project.getArtifact(), localRepository, remoteRepositories, artifactMetadataSource, new ScopeArtifactFilter(DefaultArtifact.SCOPE_COMPILE), listeners); - for (Object o : resolved.getArtifacts()) { + // add also all dependencies of the project in compile scope + Set artifacts = project.getArtifacts(); + for (Object o : artifacts) { Artifact a = (Artifact) o; - // resolv artifact (with download if required...) - if (a.getFile() == null) { - resolver.resolve(a, remoteRepositories, localRepository); - } - if (a.getFile() == null) { - throw new ArtifactNotFoundException("could not find jar", a); - } lUrls.add(a.getFile().toURI().toURL()); } } @@ -525,12 +451,6 @@ } catch (IOException e) { throw new RuntimeException("Can't create ClassLoader for script, bad directory: " + outClass + " for reason " + e.getMessage(), e); - } catch (InvalidDependencyVersionException e) { - throw new RuntimeException(e); - } catch (ArtifactResolutionException e) { - throw new RuntimeException(e); - } catch (ArtifactNotFoundException e) { - throw new RuntimeException(e); } loader = result; } else {