@@ -140,10 +140,9 @@ private void replaceVersionsWithVersionPropertyReferences(Node dependencyManagem
140
140
Node dependencies = findChild (dependencyManagement , "dependencies" );
141
141
if (dependencies != null ) {
142
142
for (Node dependency : findChildren (dependencies , "dependency" )) {
143
- String groupId = findChild (dependency , "groupId" ).text ();
144
- String artifactId = findChild (dependency , "artifactId" ).text ();
145
- Node classifierNode = findChild (dependency , "classifier" );
146
- String classifier = (classifierNode != null ) ? classifierNode .text () : "" ;
143
+ String groupId = extractText (findChild (dependency , "groupId" ));
144
+ String artifactId = extractText (findChild (dependency , "artifactId" ));
145
+ String classifier = extractText (findChild (dependency , "classifier" ));
147
146
String versionProperty = this .bom .getArtifactVersionProperty (groupId , artifactId , classifier );
148
147
if (versionProperty != null ) {
149
148
findChild (dependency , "version" ).setValue ("${" + versionProperty + "}" );
@@ -156,8 +155,8 @@ private void addExclusionsToManagedDependencies(Node dependencyManagement) {
156
155
Node dependencies = findChild (dependencyManagement , "dependencies" );
157
156
if (dependencies != null ) {
158
157
for (Node dependency : findChildren (dependencies , "dependency" )) {
159
- String groupId = findChild (dependency , "groupId" ). text ( );
160
- String artifactId = findChild (dependency , "artifactId" ). text ( );
158
+ String groupId = extractText ( findChild (dependency , "groupId" ));
159
+ String artifactId = extractText ( findChild (dependency , "artifactId" ));
161
160
this .bom .getLibraries ()
162
161
.stream ()
163
162
.flatMap ((library ) -> library .getGroups ().stream ())
@@ -179,8 +178,8 @@ private void addTypesToManagedDependencies(Node dependencyManagement) {
179
178
Node dependencies = findChild (dependencyManagement , "dependencies" );
180
179
if (dependencies != null ) {
181
180
for (Node dependency : findChildren (dependencies , "dependency" )) {
182
- String groupId = findChild (dependency , "groupId" ). text ( );
183
- String artifactId = findChild (dependency , "artifactId" ). text ( );
181
+ String groupId = extractText ( findChild (dependency , "groupId" ));
182
+ String artifactId = extractText ( findChild (dependency , "artifactId" ));
184
183
Set <String > types = this .bom .getLibraries ()
185
184
.stream ()
186
185
.flatMap ((library ) -> library .getGroups ().stream ())
@@ -207,9 +206,9 @@ private void addClassifiedManagedDependencies(Node dependencyManagement) {
207
206
Node dependencies = findChild (dependencyManagement , "dependencies" );
208
207
if (dependencies != null ) {
209
208
for (Node dependency : findChildren (dependencies , "dependency" )) {
210
- String groupId = findChild (dependency , "groupId" ). text ( );
211
- String artifactId = findChild (dependency , "artifactId" ). text ( );
212
- String version = findChild (dependency , "version" ). text ( );
209
+ String groupId = extractText ( findChild (dependency , "groupId" ));
210
+ String artifactId = extractText ( findChild (dependency , "artifactId" ));
211
+ String version = extractText ( findChild (dependency , "version" ));
213
212
Set <String > classifiers = this .bom .getLibraries ()
214
213
.stream ()
215
214
.flatMap ((library ) -> library .getGroups ().stream ())
@@ -296,6 +295,10 @@ private boolean isNodeWithName(Object candidate, String name) {
296
295
return false ;
297
296
}
298
297
298
+ private String extractText (Node node ) {
299
+ return (node != null ) ? node .text () : "" ;
300
+ }
301
+
299
302
}
300
303
301
304
}
0 commit comments