private void copyDeprecatedNbmResources()

in nbm-maven-plugin/src/main/java/org/apache/netbeans/nbm/CreateNetBeansFileStructure.java [436:491]


    private void copyDeprecatedNbmResources() throws BuildException, MojoExecutionException {
        // copy additional resources..
        List<NbmResource> ress = module.getNbmResources();
        if (ress.size() > 0) {
            getLog().warn("NBM resources defined in module descriptor are deprecated. "
                    + "Please configure NBM resources in plugin configuration.");
            Copy cp = (Copy) antProject.createTask("copy");
            cp.setTodir(clusterDir);
            HashMap<File, Collection<FileSet>> customPaths = new HashMap<>();
            boolean hasStandard = false;
            for (NbmResource res : ress) {
                if (res.getBaseDirectory() != null) {
                    File base = new File(project.getBasedir(), res.getBaseDirectory());
                    FileSet set = new FileSet();
                    set.setDir(base);
                    for (String inc : res.getIncludes()) {
                        set.createInclude().setName(inc);
                    }
                    for (String exc : res.getExcludes()) {
                        set.createExclude().setName(exc);
                    }

                    if (res.getRelativeClusterPath() != null) {
                        File path = new File(clusterDir, res.getRelativeClusterPath());
                        Collection<FileSet> col = customPaths.get(path);
                        if (col == null) {
                            col = new ArrayList<>();
                            customPaths.put(path, col);
                        }
                        col.add(set);
                    } else {
                        cp.addFileset(set);
                        hasStandard = true;
                    }
                }
            }
            try {
                if (hasStandard) {
                    cp.execute();
                }
                if (customPaths.size() > 0) {
                    for (Map.Entry<File, Collection<FileSet>> ent : customPaths.entrySet()) {
                        cp = (Copy) antProject.createTask("copy");
                        cp.setTodir(ent.getKey());
                        for (FileSet set : ent.getValue()) {
                            cp.addFileset(set);
                        }
                        cp.execute();
                    }
                }
            } catch (BuildException e) {
                getLog().error("Cannot copy additional resources into the nbm file");
                throw new MojoExecutionException(e.getMessage(), e);
            }
        }
    }