Search in sources :

Example 1 with Clazz

use of org.vafer.jdependency.Clazz in project maven-plugins by apache.

the class MinijarFilter method removePackages.

@SuppressWarnings("rawtypes")
private void removePackages(Set clazzes, Set<String> packageNames) {
    for (Object clazze : clazzes) {
        Clazz clazz = (Clazz) clazze;
        String name = clazz.getName();
        while (name.contains(".")) {
            name = name.substring(0, name.lastIndexOf('.'));
            if (packageNames.add(name)) {
                removable.remove(new Clazz(name + ".package-info"));
            }
        }
    }
}
Also used : Clazz(org.vafer.jdependency.Clazz)

Example 2 with Clazz

use of org.vafer.jdependency.Clazz in project maven-plugins by apache.

the class MinijarFilter method isFiltered.

/** {@inheritDoc} */
public boolean isFiltered(String classFile) {
    String className = classFile.replace('/', '.').replaceFirst("\\.class$", "");
    Clazz clazz = new Clazz(className);
    if (removable != null && removable.contains(clazz)) {
        log.debug("Removing " + className);
        classesRemoved += 1;
        return true;
    }
    classesKept += 1;
    return false;
}
Also used : Clazz(org.vafer.jdependency.Clazz)

Example 3 with Clazz

use of org.vafer.jdependency.Clazz in project maven-plugins by apache.

the class MinijarFilter method removeSpecificallyIncludedClasses.

private void removeSpecificallyIncludedClasses(MavenProject project, List<SimpleFilter> simpleFilters) throws IOException {
    // remove classes specifically included in filters
    Clazzpath checkCp = new Clazzpath();
    for (Artifact dependency : project.getArtifacts()) {
        File jar = dependency.getFile();
        for (SimpleFilter simpleFilter : simpleFilters) {
            if (simpleFilter.canFilter(jar)) {
                ClazzpathUnit depClazzpathUnit = addDependencyToClasspath(checkCp, dependency);
                if (depClazzpathUnit != null) {
                    Set<Clazz> clazzes = depClazzpathUnit.getClazzes();
                    Iterator<Clazz> j = removable.iterator();
                    while (j.hasNext()) {
                        Clazz clazz = j.next();
                        if (//
                        clazzes.contains(clazz) && simpleFilter.isSpecificallyIncluded(clazz.getName().replace('.', '/'))) {
                            log.info(clazz.getName() + " not removed because it was specifically included");
                            j.remove();
                        }
                    }
                }
            }
        }
    }
}
Also used : Clazzpath(org.vafer.jdependency.Clazzpath) ClazzpathUnit(org.vafer.jdependency.ClazzpathUnit) Clazz(org.vafer.jdependency.Clazz) File(java.io.File) Artifact(org.apache.maven.artifact.Artifact)

Aggregations

Clazz (org.vafer.jdependency.Clazz)3 File (java.io.File)1 Artifact (org.apache.maven.artifact.Artifact)1 Clazzpath (org.vafer.jdependency.Clazzpath)1 ClazzpathUnit (org.vafer.jdependency.ClazzpathUnit)1