4
4
import com .eternalcode .core .loader .dependency .DependencyCollector ;
5
5
import com .eternalcode .core .loader .repository .Repository ;
6
6
import java .io .File ;
7
- import java .net .URISyntaxException ;
8
- import java .nio .file .Files ;
9
- import java .nio .file .StandardCopyOption ;
10
- import org .w3c .dom .Document ;
11
- import org .w3c .dom .Element ;
12
- import org .w3c .dom .NodeList ;
13
- import org .xml .sax .SAXException ;
14
-
15
- import javax .xml .XMLConstants ;
16
- import javax .xml .parsers .DocumentBuilder ;
17
- import javax .xml .parsers .DocumentBuilderFactory ;
18
- import javax .xml .parsers .ParserConfigurationException ;
19
7
import java .io .IOException ;
20
8
import java .io .InputStream ;
9
+ import java .net .URISyntaxException ;
21
10
import java .net .URL ;
11
+ import java .nio .file .Files ;
12
+ import java .nio .file .StandardCopyOption ;
22
13
import java .util .ArrayList ;
23
14
import java .util .Collections ;
24
15
import java .util .List ;
25
16
import java .util .Optional ;
17
+ import javax .xml .XMLConstants ;
18
+ import javax .xml .parsers .DocumentBuilder ;
19
+ import javax .xml .parsers .DocumentBuilderFactory ;
20
+ import javax .xml .parsers .ParserConfigurationException ;
21
+ import org .w3c .dom .Document ;
22
+ import org .w3c .dom .Element ;
23
+ import org .w3c .dom .NodeList ;
24
+ import org .xml .sax .SAXException ;
26
25
27
26
public class PomXmlScanner implements DependencyScanner {
28
27
@@ -37,7 +36,8 @@ public class PomXmlScanner implements DependencyScanner {
37
36
DOCUMENT_BUILDER_FACTORY .setFeature ("http://apache.org/xml/features/nonvalidating/load-external-dtd" , false );
38
37
DOCUMENT_BUILDER_FACTORY .setXIncludeAware (false );
39
38
DOCUMENT_BUILDER_FACTORY .setExpandEntityReferences (false );
40
- } catch (ParserConfigurationException exception ) {
39
+ }
40
+ catch (ParserConfigurationException exception ) {
41
41
throw new RuntimeException ("Failed to configure XML parser" , exception );
42
42
}
43
43
}
@@ -83,14 +83,14 @@ private Optional<List<Dependency>> tryReadDependency(Dependency dependency, Repo
83
83
List <Dependency > dependencies = this .readDependency (pomXml );
84
84
85
85
return Optional .of (dependencies );
86
-
87
86
}
88
87
catch (IOException | SAXException | ParserConfigurationException | URISyntaxException exception ) {
89
88
return Optional .empty ();
90
89
}
91
90
}
92
91
93
- private File savePomXmlToLocalRepository (Dependency dependency , Repository repository ) throws URISyntaxException , IOException {
92
+ private File savePomXmlToLocalRepository (Dependency dependency , Repository repository )
93
+ throws URISyntaxException , IOException {
94
94
File localFile = dependency .toPomXml (this .localRepository ).toFile ();
95
95
96
96
if (localFile .exists () && !this .isEmpty (localFile )) {
@@ -110,7 +110,8 @@ private File savePomXmlToLocalRepository(Dependency dependency, Repository repos
110
110
private boolean isEmpty (File file ) {
111
111
try {
112
112
return Files .size (file .toPath ()) == 0 ;
113
- } catch (IOException exception ) {
113
+ }
114
+ catch (IOException exception ) {
114
115
return true ;
115
116
}
116
117
}
@@ -163,5 +164,4 @@ private List<Dependency> readDependency(File file) throws ParserConfigurationExc
163
164
164
165
return Collections .unmodifiableList (dependencies );
165
166
}
166
-
167
167
}
0 commit comments