List dependencies()

in plugins/maven/src/main/java/org/wildfly/swarm/plugin/maven/StartMojo.java [308:383]


    List<Path> dependencies(final Path archiveContent,
                            final boolean scanDependencies) throws MojoFailureException {
        final List<Path> elements = new ArrayList<>();
        final Set<Artifact> artifacts = this.project.getArtifacts();
        boolean hasSwarmDeps = false;

        List<Artifact> artifactsSorted = new ArrayList<>(artifacts.size());
        for (Artifact artifact : artifacts) {
            if (artifact.getGroupId().equals(FractionDescriptor.THORNTAIL_GROUP_ID)
                    && artifact.getArtifactId().equals(DependencyManager.WILDFLY_SWARM_BOOTSTRAP_ARTIFACT_ID)) {
                artifactsSorted.add(0, artifact);
            } else {
                artifactsSorted.add(artifact);
            }
        }

        final DeclaredDependencies declaredDependencies = new DeclaredDependencies();

        for (Artifact each : artifactsSorted) {

            String parentDep = each.getDependencyTrail().get(1);

            declaredDependencies.add(DeclaredDependencies.createSpec(parentDep), DeclaredDependencies.createSpec(each.toString()));

            if (each.getGroupId().equals(FractionDescriptor.THORNTAIL_GROUP_ID)
                    && each.getArtifactId().equals(DependencyManager.WILDFLY_SWARM_BOOTSTRAP_ARTIFACT_ID)) {
                hasSwarmDeps = true;
            }
            if (each.getGroupId().equals("org.jboss.logmanager")
                    && each.getArtifactId().equals("jboss-logmanager")) {
                continue;
            }
            if (each.getScope().equals("provided")) {
                continue;
            }
            elements.add(each.getFile().toPath());
        }

        if (declaredDependencies.getDirectDeps().size() > 0) {
            try {

                // multi-start doesn't have a projectBuildDir

                File tmp = this.projectBuildDir != null ?
                        Files.createTempFile(Paths.get(this.projectBuildDir), TempFileManager.WFSWARM_TMP_PREFIX, "-cp.txt").toFile() :
                        Files.createTempFile(TempFileManager.WFSWARM_TMP_PREFIX, "-cp.txt").toFile();

                tmp.deleteOnExit();
                getPluginContext().put("thorntail-cp-file", tmp);
                declaredDependencies.writeTo(tmp);
                getLog().debug("dependency info stored at: " + tmp.getAbsolutePath());
                this.properties.setProperty("thorntail.cp.info", tmp.getAbsolutePath());

            } catch (IOException e) {
                throw new RuntimeException(e.getMessage());
            }
        }

        elements.add(Paths.get(this.project.getBuild().getOutputDirectory()));

        if (fractionDetectMode != BuildTool.FractionDetectionMode.never) {
            if (fractionDetectMode == BuildTool.FractionDetectionMode.force ||
                    !hasSwarmDeps) {
                List<Path> fractionDeps = findNeededFractions(artifactsSorted, archiveContent, scanDependencies);
                for (Path p : fractionDeps) {
                    if (!elements.contains(p)) {
                        elements.add(p);
                    }
                }
            }
        } else if (!hasSwarmDeps) {
            getLog().warn("No Thorntail dependencies found and fraction detection disabled");
        }

        return elements;
    }