Dennis Kao
2013-06-05 fc9880cd77a09dcfdea2791dee418f54f5721cf3
xdgnjobs/ximple-build/maven/jar-collector/src/main/java/com/ximple/eofms/maven/JarCollector.java
@@ -55,14 +55,6 @@
    private String jarName;
    /**
     * Project dependencies.
     *
     * @parameter expression="${project.artifacts}"
     * @required
     */
    private Set /*<Artifact>*/ dependencies;
    /**
     * The Maven project running this plugin.
     *
     * @parameter expression="${project}"
@@ -118,7 +110,7 @@
        if (!collect.exists()) {
            if (!collect.mkdir()) {
                throw new MojoExecutionException("Failed to create target directory.");
                throw new MojoExecutionException("Failed to create target directory: " + collect.getAbsolutePath());
            }
        }
@@ -145,29 +137,30 @@
        int count = 1;
        FileUtils.copyFileToDirectory(jarFile, collect);
        Set<Artifact> dependencies = project.getDependencyArtifacts();
        if (dependencies != null) {
            for (final Iterator it = dependencies.iterator(); it.hasNext();) {
                final Artifact artifact = (Artifact) it.next();
            for (final Artifact artifact : dependencies) {
                System.out.println("+++++++++++++++++++++++ DEP: " + artifact.getDependencyTrail());
                final String scope = artifact.getScope();
                if ((scope != null) // Maven 2.0.6 bug?
                        && (scope.equalsIgnoreCase(Artifact.SCOPE_COMPILE)
                        || scope.equalsIgnoreCase(Artifact.SCOPE_RUNTIME))) {
                if (scope != null &&  // Maven 2.0.6 bug?
                        (scope.equalsIgnoreCase(Artifact.SCOPE_COMPILE) ||
                                scope.equalsIgnoreCase(Artifact.SCOPE_RUNTIME)))
                {
                    final File file = artifact.getFile();
                    final File copy = new File(collect, file.getName());
                    if (!copy.exists()) {
                        /*
                         * Copies the dependency only if it was not already copied. Note that
                         * the module's JAR was copied inconditionnaly above (because it may
                         * be the result of a new compilation). If a Geotools JAR from the
                         * dependencies list changed, it will be copied inconditionnaly when
                         * the module for this JAR will be processed by Maven.
                         */
                        FileUtils.copyFileToDirectory(file, collect);
                        count++;
                    if (!artifact.getGroupId().startsWith("com.ximple.eofms")) {
                        final File copy = new File(collect, file.getName());
                        if (copy.exists()) {
                            /*
                             * Copies the dependency only if it was not already copied. Note that
                             * the module's JAR was copied inconditionnaly above (because it may
                             * be the result of a new compilation). If a Geotools JAR from the
                             * dependencies list changed, it will be copied inconditionnaly when
                             * the module for this JAR will be processed by Maven.
                             */
                            continue;
                        }
                    }
                    FileUtils.copyFileToDirectory(file, collect);
                }
            }
        }