Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tycho-4.0.x] Do not fail the DS build if one dependency failed to add #3627

Merged
merged 1 commit into from
Mar 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -162,14 +165,18 @@ public void execute() throws MojoExecutionException, MojoFailureException {
for (ClasspathEntry entry : classpath) {
List<File> 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<ClasspathEntry> list = cpc.getAdditionalClasspathEntries(project,
Artifact.SCOPE_COMPILE);
List<ClasspathEntry> list = cpc.getAdditionalClasspathEntries(project, Artifact.SCOPE_COMPILE);
if (list != null && !list.isEmpty()) {
for (ClasspathEntry entry : list) {
for (File file : entry.getLocations()) {
Expand All @@ -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
Expand All @@ -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()) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand Down
Loading