Skip to content

Commit c7575c7

Browse files
committed
GBLD-2003: update manifest if there are changes in outputDirectory
If new (generated) classes are compiled between full build and incremental build, bnd-maven-plugin didn't recognize the changes. We compare now manifest last modified timestamp with newly calculated last modified timestamp based on output directory and dependencies. (re-made from 6142206)
1 parent 2c925e2 commit c7575c7

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

maven-plugins/bnd-maven-plugin/src/main/java/aQute/bnd/maven/plugin/AbstractBndMavenPlugin.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
349349
logger.debug("builder classpath: {}", builder.getProperty("project.buildpath"));
350350

351351
// Compute bnd sourcepath
352-
boolean delta = !buildContext.isIncremental() || outOfDate();
352+
boolean delta = !buildContext.isIncremental() || outOfDate(builder.lastModified());
353353
List<File> sourcepath = new ArrayList<>();
354354
if (getSourceDir().exists()) {
355355
sourcepath.add(getSourceDir().getCanonicalFile());
@@ -446,7 +446,7 @@ protected void processBuildPath(List<Object> buildpath) {}
446446

447447
private void attachArtifactToProject(Jar bndJar) throws Exception {
448448
File artifactFile = getArtifactFile();
449-
if (outOfDate(artifactFile) || artifactFile.lastModified() < bndJar.lastModified()) {
449+
if (outOfDate(artifactFile, bndJar.lastModified())) {
450450
if (logger.isDebugEnabled()) {
451451
if (artifactFile.exists())
452452
logger.debug(String.format("Updating lastModified: %tF %<tT.%<tL '%s'", artifactFile.lastModified(),
@@ -622,9 +622,9 @@ private void writeContent(Jar jar, File directory) throws Exception {
622622

623623
private void writeManifest(Jar jar, File manifestPath) throws Exception {
624624
final long lastModified = jar.lastModified();
625-
if (outOfDate(manifestPath) || manifestPath.lastModified() < lastModified) {
625+
if (outOfDate(manifestPath, lastModified)) {
626626
if (logger.isDebugEnabled()) {
627-
if (!outOfDate(manifestPath))
627+
if (manifestPath.isFile())
628628
logger.debug(String.format("Updating lastModified: %tF %<tT.%<tL '%s'",
629629
manifestPath.lastModified(), manifestPath));
630630
else
@@ -639,13 +639,13 @@ private void writeManifest(Jar jar, File manifestPath) throws Exception {
639639
}
640640
}
641641

642-
private boolean outOfDate() {
642+
private boolean outOfDate(long lm) {
643643
String goal = mojoExecution.getMojoDescriptor()
644644
.getGoal();
645-
return outOfDate(isPackagingGoal(goal) ? getArtifactFile() : getManifestPath());
645+
return outOfDate(isPackagingGoal(goal) ? getArtifactFile() : getManifestPath(), lm);
646646
}
647647

648-
private boolean outOfDate(File target) {
648+
private boolean outOfDate(File target, long lm) {
649649
if (!target.isFile()) {
650650
return true;
651651
}
@@ -654,6 +654,7 @@ private boolean outOfDate(File target) {
654654
if (buildContext.getValue(LAST_MODIFIED) != null) {
655655
lastModified = (Long) buildContext.getValue(LAST_MODIFIED);
656656
}
657-
return target.lastModified() != lastModified;
657+
return target.lastModified() != lastModified
658+
|| target.lastModified() < lm;
658659
}
659660
}

0 commit comments

Comments
 (0)