diff --git a/tycho-ds-plugin/src/main/java/org/eclipse/tycho/ds/DeclarativeServicesMojo.java b/tycho-ds-plugin/src/main/java/org/eclipse/tycho/ds/DeclarativeServicesMojo.java index c67396199e..e7e502cf8a 100644 --- a/tycho-ds-plugin/src/main/java/org/eclipse/tycho/ds/DeclarativeServicesMojo.java +++ b/tycho-ds-plugin/src/main/java/org/eclipse/tycho/ds/DeclarativeServicesMojo.java @@ -23,6 +23,7 @@ import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.plugin.logging.Log; import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; @@ -145,7 +146,9 @@ public void execute() throws MojoExecutionException, MojoFailureException { return; } Version dsVersion = configuration.getSpecificationVersion(); - getLog().info("Using Declarative Service specification version " + dsVersion + " to generate component definitions"); + Log log = getLog(); + log.info("Using Declarative Service specification version " + dsVersion + + " to generate component definitions"); boolean isDs12 = dsVersion.getMajor() == 1 && dsVersion.getMinor() == 2; String childPath = configuration.getPath(); File targetDirectory = new File(outputDirectory, childPath); @@ -162,14 +165,18 @@ public void execute() throws MojoExecutionException, MojoFailureException { for (ClasspathEntry entry : classpath) { List locations = entry.getLocations(); for (File file : locations) { - if (file.exists() && !file.equals(outputDirectory)) { - analyzer.addClasspath(file); + if (file.exists() && !file.equals(outputDirectory) && file.length() > 0) { + try { + analyzer.addClasspath(file); + } catch (IOException e) { + log.warn("Can't add file " + file + " as classpath entry to ds analyzer", + log.isDebugEnabled() ? e : null); + } } } } pluginRealmHelper.visitPluginExtensions(project, session, ClasspathContributor.class, cpc -> { - List list = cpc.getAdditionalClasspathEntries(project, - Artifact.SCOPE_COMPILE); + List list = cpc.getAdditionalClasspathEntries(project, Artifact.SCOPE_COMPILE); if (list != null && !list.isEmpty()) { for (ClasspathEntry entry : list) { for (File file : entry.getLocations()) { @@ -183,7 +190,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { }); if (isDs12) { // see https://github.com/bndtools/bnd/issues/5548 - getLog().warn( + log.warn( "Generating of XML DS 1.2 might be not fully supported and validation is disabled (see https://github.com/bndtools/bnd/issues/5548), please upgrade to at least 1.3"); } else { // https://bnd.bndtools.org/instructions/dsannotations-options.html @@ -193,13 +200,14 @@ public void execute() throws MojoExecutionException, MojoFailureException { analyzer.addBasicPlugin(new DSAnnotations()); analyzer.analyze(); for (String warning : analyzer.getWarnings()) { - getLog().warn(warning); + log.warn(warning); } for (String error : analyzer.getErrors()) { - getLog().error(error); + log.error(error); } if (!analyzer.getErrors().isEmpty()) { - throw new MojoFailureException("Generation of Declarative Service components failed, see log for details"); + throw new MojoFailureException( + "Generation of Declarative Service components failed, see log for details"); } String components = analyzer.getProperty(SERVICE_COMPONENT_HEADER); if (components == null || components.isBlank()) { @@ -219,7 +227,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { keep++; continue; } - getLog().info("\t" + name); + log.info("\t" + name); generated++; Resource resource = analyzer.getJar().getResource(component); if (resource != null) { @@ -229,9 +237,9 @@ public void execute() throws MojoExecutionException, MojoFailureException { } } if (keep > 0) { - getLog().info(generated + " component(s) where generated, " + keep + " where kept."); + log.info(generated + " component(s) where generated, " + keep + " where kept."); } else { - getLog().info(generated + " component(s) where generated."); + log.info(generated + " component(s) where generated."); } } } catch (Exception e) {