data-collector/src/main/java/se/kth/depclean/experiments/analysis/ProjectDependencyAnalysis.java
/**
     * Force use status of some declared dependencies, to manually fix consequences of bytecode-level analysis which
     * happens to not detect some effective use (constants, annotation with source-retention, javadoc).
     *
     * @param forceUsedDependencies dependencies to move from "unused-declared" to "used-declared", with
     *                              <code>groupId:artifactId</code> format
     * @return updated project dependency analysis
     * @throws ProjectDependencyAnalyzerException if dependencies forced were either not declared or already detected as
     *                                            used
     * @since 1.3
     */
Force use status of some declared dependencies, to manually fix consequences of bytecode-level analysis which
happens to not detect some effective use (constants, annotation with source-retention, javadoc).

@param forceUsedDependencies dependencies to move from "unused-declared" to "used-declared", with
groupId:artifactId format
@return updated project dependency analysis
@throws ProjectDependencyAnalyzerException if dependencies forced were either not declared or already detected as
used
@since 1.3
Force use status of some declared dependencies to manually fix consequences of bytecode - level analysis which happens to not detect some effective use ( constants annotation with source - retention javadoc ) . @param forceUsedDependencies dependencies to move from " unused - declared " to " used - declared " with groupId : artifactId format @return updated project dependency analysis @throws ProjectDependencyAnalyzerException if dependencies forced were either not declared or already detected as used @since 1 . 3
public ProjectDependencyAnalysis forceDeclaredDependenciesUsage(String[] forceUsedDependencies)
            throws ProjectDependencyAnalyzerException {
        Set<String> forced = new HashSet<String>(Arrays.asList(forceUsedDependencies));
        Set<Artifact> forcedUnusedDeclared = new HashSet<Artifact>(unusedDeclaredArtifacts);
        Set<Artifact> forcedUsedDeclared = new HashSet<Artifact>(usedDeclaredArtifacts);
        for (Iterator<Artifact> iter = forcedUnusedDeclared.iterator(); iter.hasNext(); ) {
            Artifact artifact = iter.next();
            if (forced.remove(artifact.getGroupId() + ':' + artifact.getArtifactId())) {
                iter.remove();
                forcedUsedDeclared.add(artifact);
            }
        }
        if (!forced.isEmpty()) {
            Set<String> used = new HashSet<String>();
            for (Artifact artifact : usedDeclaredArtifacts) {
                String id = artifact.getGroupId() + ':' + artifact.getArtifactId();
                if (forced.remove(id)) {
                    used.add(id);
                }
            }
            StringBuilder builder = new StringBuilder();
            if (!forced.isEmpty()) {
                builder.append("not declared: ").append(forced);
            }
            if (!used.isEmpty()) {
                if (builder.length() > 0) {
                    builder.append(" and ");
                }
                builder.append("declared but already detected as used: ").append(used);
            }
            throw new ProjectDependencyAnalyzerException("Trying to force use of dependencies which are " + builder);
        }
        return new ProjectDependencyAnalysis(forcedUsedDeclared, usedUndeclaredArtifacts, forcedUnusedDeclared);
    }
public ProjectDependencyAnalysis forceDeclaredDependenciesUsage ( String [ ] forceUsedDependencies ) throws ProjectDependencyAnalyzerException { Set < String > forced = new HashSet < String > ( Arrays . asList ( forceUsedDependencies ) ) ; Set < Artifact > forcedUnusedDeclared = new HashSet < Artifact > ( unusedDeclaredArtifacts ) ; Set < Artifact > forcedUsedDeclared = new HashSet < Artifact > ( usedDeclaredArtifacts ) ; for ( Iterator < Artifact > iter = forcedUnusedDeclared . iterator ( ) ; iter . hasNext ( ) ; ) { Artifact artifact = iter . next ( ) ; if ( forced . remove ( artifact . getGroupId ( ) + ':' + artifact . getArtifactId ( ) ) ) { iter . remove ( ) ; forcedUsedDeclared . add ( artifact ) ; } } if ( ! forced . isEmpty ( ) ) { Set < String > used = new HashSet < String > ( ) ; for ( Artifact artifact : usedDeclaredArtifacts ) { String id = artifact . getGroupId ( ) + ':' + artifact . getArtifactId ( ) ; if ( forced . remove ( id ) ) { used . add ( id ) ; } } StringBuilder builder = new StringBuilder ( ) ; if ( ! forced . isEmpty ( ) ) { builder . append ( "not declared: " ) . append ( forced ) ; } if ( ! used . isEmpty ( ) ) { if ( builder . length ( ) > 0 ) { builder . append ( " and " ) ; } builder . append ( "declared but already detected as used: " ) . append ( used ) ; } throw new ProjectDependencyAnalyzerException ( "Trying to force use of dependencies which are " + builder ) ; } return new ProjectDependencyAnalysis ( forcedUsedDeclared , usedUndeclaredArtifacts , forcedUnusedDeclared ) ; }
Force use status of some declared dependencies, to manually fix consequences of bytecode-level analysis which
 happens to not detect some effective use (constants, annotation with source-retention, javadoc).
Force use status of some declared dependencies to manually fix consequences of bytecode - level analysis which happens to not detect some effective use ( constants annotation with source - retention javadoc ) .
// ok, change artifact status from unused-declared to used-declared // trying to force dependencies as used-declared which were not declared or already detected as used