forked from geodmms/xdgnjobs

Dennis Kao
2013-11-25 3106989d98d9dcc5578955ed1395e29dea5a217f
xdgnjobs/ximple-build/maven/jar-collector/src/main/java/com/ximple/eofms/maven/JarCollector.java
@@ -72,13 +72,10 @@
         * Gets the parent "target" directory.
         */
        MavenProject parent = project;
        while (parent.hasParent()) {
            parent = parent.getParent();
        }
        collectDirectory = parent.getBuild().getDirectory();
        /*
         * Now collects the JARs.
         */
@@ -98,22 +95,18 @@
         * such file. Some modules use pom packaging, which do not produce any JAR file.
         */
        final File jarFile = new File(outputDirectory, jarName + ".jar");
        if (!jarFile.isFile()) {
            return;
        }
        /*
         * Get the "target" directory of the parent pom.xml and make sure it exists.
         */
        File collect = new File(collectDirectory);
        if (!collect.exists()) {
            if (!collect.mkdir()) {
                throw new MojoExecutionException("Failed to create target directory: " + collect.getAbsolutePath());
            }
        }
        if (collect.getCanonicalFile().equals(jarFile.getParentFile().getCanonicalFile())) {
            /*
             * The parent's directory is the same one than this module's directory.
@@ -123,31 +116,27 @@
             */
            return;
        }
        /*
         * Creates a "binaries" subdirectory inside the "target" directory.
         */
        collect = new File(collect, SUB_DIRECTORY);
        if (!collect.exists()) {
            if (!collect.mkdir()) {
                throw new MojoExecutionException("Failed to create binaries directory.");
            }
        }
        int count = 1;
        FileUtils.copyFileToDirectory(jarFile, collect);
        Set<Artifact> dependencies = project.getDependencyArtifacts();
      Set<Artifact> dependencies = project.getDependencyArtifacts();
        if (dependencies != null) {
            for (final Artifact artifact : dependencies) {
                System.out.println("+++++++++++++++++++++++ DEP: " + artifact.getDependencyTrail());
            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)))
                   (scope.equalsIgnoreCase(Artifact.SCOPE_COMPILE) ||
                    scope.equalsIgnoreCase(Artifact.SCOPE_RUNTIME)))
                {
                    final File file = artifact.getFile();
                    if (!artifact.getGroupId().startsWith("com.ximple.eofms")) {
                    if (!artifact.getGroupId().startsWith("org.geotools")) {
                        final File copy = new File(collect, file.getName());
                        if (copy.exists()) {
                            /*
@@ -164,7 +153,5 @@
                }
            }
        }
        getLog().info("Copied " + count + " JAR to parent directory.");
    }
}