2727import java .util .Arrays ;
2828import java .util .List ;
2929import java .util .Set ;
30+ import java .util .jar .Attributes ;
31+ import java .util .jar .JarFile ;
32+ import java .util .jar .Manifest ;
3033import java .util .stream .Collectors ;
3134
3235import org .apache .commons .io .FileUtils ;
@@ -181,10 +184,9 @@ public void execute() throws MojoExecutionException, MojoFailureException {
181184 getLog ().info ("update-frontend took " + ms + "ms." );
182185 }
183186
184- private void runNodeUpdater () throws ExecutionFailedException , MojoExecutionException {
185- Set <File > jarFiles = project .getArtifacts ().stream ()
186- .filter (artifact -> "jar" .equals (artifact .getType ()))
187- .map (Artifact ::getFile ).collect (Collectors .toSet ());
187+ private void runNodeUpdater ()
188+ throws ExecutionFailedException , MojoExecutionException {
189+ Set <File > jarFiles = getJarFiles ();
188190
189191 final URI nodeDownloadRootURI ;
190192 if (nodeDownloadRoot == null ) {
@@ -278,8 +280,9 @@ private void validateLicenses() {
278280 throw new RuntimeException (
279281 "Stats file " + statsFile + " does not exist" );
280282 }
281- List <Product > commercialComponents = findCommercialComponents (
283+ List <Product > commercialComponents = findCommercialFrontendComponents (
282284 nodeModulesFolder , statsFile );
285+ commercialComponents .addAll (findCommercialJavaComponents ());
283286
284287 for (Product component : commercialComponents ) {
285288 try {
@@ -305,7 +308,7 @@ private static Logger getLogger() {
305308 return LoggerFactory .getLogger (BuildFrontendMojo .class );
306309 }
307310
308- private static List <Product > findCommercialComponents (
311+ private static List <Product > findCommercialFrontendComponents (
309312 File nodeModulesFolder , File statsFile ) {
310313 List <Product > components = new ArrayList <>();
311314 try (InputStream in = new FileInputStream (statsFile )) {
@@ -326,6 +329,37 @@ private static List<Product> findCommercialComponents(
326329
327330 }
328331
332+ private List <Product > findCommercialJavaComponents () {
333+ List <Product > components = new ArrayList <>();
334+
335+ for (File f : getJarFiles ()) {
336+ try (JarFile jarFile = new JarFile (f )) {
337+ Manifest manifest = jarFile .getManifest ();
338+ if (manifest == null ) {
339+ continue ;
340+ }
341+ Attributes attributes = manifest .getMainAttributes ();
342+ if (attributes == null ) {
343+ continue ;
344+ }
345+ String cvdlName = attributes .getValue ("CvdlName" );
346+ if (cvdlName != null ) {
347+ String version = attributes .getValue ("Bundle-Version" );
348+ Product p = new Product (cvdlName , version );
349+ components .add (p );
350+ }
351+ } catch (IOException e ) {
352+ getLogger ().debug ("Error reading manifest for jar " + f , e );
353+ }
354+ }
355+
356+ return components ;
357+ }
358+
359+ private Set <File > getJarFiles () {
360+ return project .getArtifacts ().stream ().filter (artifact -> "jar" .equals (artifact .getType ())).map (Artifact ::getFile ).collect (Collectors .toSet ());
361+ }
362+
329363 private FrontendTools getFrontendTools () throws MojoExecutionException {
330364 final URI nodeDownloadRootURI ;
331365 try {
0 commit comments