data-collector/src/main/java/se/kth/depclean/experiments/util/CustomFileWriter.java
/**
     * Writes a file with descriptive fields of the studied artifacts locally.
     */
Writes a file with descriptive fields of the studied artifacts locally.
Writes a file with descriptive fields of the studied artifacts locally .
public static void writeArtifactProperties(String descriptionPath, Model model, String coordinates, DependencyTreeAnalyzer dta, DependencyTreeAnalyzer dtaDebloated,
                                               long nbVisitedTypes, long nbVisitedFields, long nbVisitedMethods, long nbVisitedAnnotations) throws IOException {
        BufferedWriter bw = new BufferedWriter(new FileWriter(descriptionPath, true));
        bw.write(coordinates + ",");
        bw.write(nbVisitedTypes + "," +
                nbVisitedFields + "," +
                nbVisitedMethods + "," +
                nbVisitedAnnotations + ",");
        String parentCoordinates = "NO";
        if (model.getParent() != null) {
            parentCoordinates = "YES";
        }
        bw.write(parentCoordinates + ",");
        Organization organization = model.getOrganization();
        if (organization != null) {
            bw.write(organization.getName().replaceAll(",", "[comma]").replaceAll("\n", " ") + ",");
        } else {
            bw.write("NA,");
        }
        Scm scm = model.getScm();
        if (scm != null) {
            if (scm.getUrl() != null) {
                bw.write(scm.getUrl().replaceAll(",", "[comma]").replaceAll("\n", " ") + ",");
            }
        } else {
            bw.write("NA,");
        }
        List<License> licencesList = model.getLicenses();
        if (!licencesList.isEmpty()) {
            bw.write(licencesList.get(0).getName().replaceAll(",", "[comma]").replaceAll("\n", " ") + ",");
        } else {
            bw.write("NA,");
        }
        bw.write(dta.heightOfDependencyTree() + "," + dtaDebloated.heightOfDependencyTree() + "\n");
        bw.close();
    }
public static void writeArtifactProperties ( String descriptionPath , Model model , String coordinates , DependencyTreeAnalyzer dta , DependencyTreeAnalyzer dtaDebloated , long nbVisitedTypes , long nbVisitedFields , long nbVisitedMethods , long nbVisitedAnnotations ) throws IOException { BufferedWriter bw = new BufferedWriter ( new FileWriter ( descriptionPath , true ) ) ; bw . write ( coordinates + "," ) ; bw . write ( nbVisitedTypes + "," + nbVisitedFields + "," + nbVisitedMethods + "," + nbVisitedAnnotations + "," ) ; String parentCoordinates = "NO" ; if ( model . getParent ( ) != null ) { parentCoordinates = "YES" ; } bw . write ( parentCoordinates + "," ) ; Organization organization = model . getOrganization ( ) ; if ( organization != null ) { bw . write ( organization . getName ( ) . replaceAll ( "," , "[comma]" ) . replaceAll ( "\n" , " " ) + "," ) ; } else { bw . write ( "NA," ) ; } Scm scm = model . getScm ( ) ; if ( scm != null ) { if ( scm . getUrl ( ) != null ) { bw . write ( scm . getUrl ( ) . replaceAll ( "," , "[comma]" ) . replaceAll ( "\n" , " " ) + "," ) ; } } else { bw . write ( "NA," ) ; } List < License > licencesList = model . getLicenses ( ) ; if ( ! licencesList . isEmpty ( ) ) { bw . write ( licencesList . get ( 0 ) . getName ( ) . replaceAll ( "," , "[comma]" ) . replaceAll ( "\n" , " " ) + "," ) ; } else { bw . write ( "NA," ) ; } bw . write ( dta . heightOfDependencyTree ( ) + "," + dtaDebloated . heightOfDependencyTree ( ) + "\n" ) ; bw . close ( ) ; }
Writes a file with descriptive fields of the studied artifacts locally.
Writes a file with descriptive fields of the studied artifacts locally .
// write coordinates // write static analysis stats // parent in case of multi module projects //            parentCoordinates = MavenDependencyUtils.toCoordinates(model.getParent().getGroupId(), model.getParent().getArtifactId(), model.getParent().getVersion()); // write organization // write scm // write licences // write height of original and debloated dependency trees