protected List < Dependency > readDependenciesFromFile ( String resolvedFileName , String dependencyType ) throws IOException { List < Dependency > dependencies = new ArrayList < Dependency > ( ) ; File resolvedFile = new File ( resolvedFileName ) ; if ( ! resolvedFile . exists ( ) ) { return dependencies ; } FileInputStream fstream = new FileInputStream ( resolvedFile ) ; DataInputStream ds = new DataInputStream ( fstream ) ; BufferedReader br = new BufferedReader ( new InputStreamReader ( ds ) ) ; Pattern p = Pattern . compile ( " (.*):(.*):" + dependencyType + ":(.*):(.*)" ) ; // keep only selected type (projlib or jar or bw-ear) dependencies String strLine ; while ( ( strLine = br . readLine ( ) ) != null ) { Matcher m = p . matcher ( strLine ) ; if ( m . matches ( ) ) { getLog ( ) . debug ( m . group ( 0 ) ) ; String groupId = m . group ( 1 ) ; String artifactId = m . group ( 2 ) ; String version = m . group ( 3 ) ; String scope = m . group ( 4 ) ; // create the dependency Dependency dependency = new Dependency ( ) ; dependency . setGroupId ( groupId ) ; dependency . setArtifactId ( artifactId ) ; dependency . setVersion ( version ) ; dependency . setType ( dependencyType ) ; dependency . setScope ( scope ) ; dependencies . add ( dependency ) ; } } br . close ( ) ; return dependencies ; }
This will read the dependencies from the resolved file found in the build directory . This file was created earlier in the build by the resolve - bw - dependencies execution of the process - resources phase .