Skip to content

Commit 9d0c2ea

Browse files
committed
log in github action
Signed-off-by: Christoph Rueger <[email protected]>
1 parent ad34737 commit 9d0c2ea

2 files changed

Lines changed: 41 additions & 13 deletions

File tree

gradle-plugins/biz.aQute.bnd.gradle/src/main/java/aQute/bnd/gradle/BndPlugin.java

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -594,19 +594,28 @@ public void execute(Task tt) {
594594
project.getGradle().getSharedServices().registerIfAbsent(
595595
"bndReleaseCounter",
596596
ReleaseCounterService.class,
597-
spec -> { /* no params */ }
597+
spec -> {
598+
spec.getMaxParallelUsages()
599+
.set(1);
600+
}
598601
);
599602

600-
project.getGradle().getTaskGraph().whenReady(graph -> {
601-
long count = graph.getAllTasks().stream()
602-
.filter(t -> t.getName().equals("release"))
603-
.filter(Task::getEnabled)
604-
.count();
605-
606-
// helpful while you validate:
607-
project.getLogger().lifecycle("bnd: release tasks in execution graph = {}", count);
608-
609-
releaseCounter.get().setInitialCount((int) count);
603+
project.getGradle()
604+
.getTaskGraph()
605+
.whenReady(graph -> {
606+
long count = graph.getAllTasks()
607+
.stream()
608+
.filter(t -> t.getName()
609+
.equals("release"))
610+
.filter(Task::getEnabled)
611+
.count();
612+
613+
// helpful while you validate:
614+
project.getLogger()
615+
.lifecycle("bnd: release tasks in execution graph = {}", count);
616+
617+
releaseCounter.get()
618+
.setInitialCount((int) count);
610619
});
611620

612621
TaskProvider<Task> release = tasks.register("release", t -> {
@@ -629,13 +638,20 @@ public void execute(Task tt) {
629638
public void execute(Task tt) {
630639
try {
631640

632-
boolean isLastBundle = releaseCounter.get().isLastReleaseTask();
641+
int count = releaseCounter.get()
642+
.getRemaining();
643+
boolean isLastBundle = releaseCounter.get()
644+
.isLastReleaseTask();
645+
633646
if (!isLastBundle) {
647+
tt.getLogger()
648+
.lifecycle("bnd: Release bundle ({}) {}", count, jar.getName());
634649
bndProject.release();
635650
} else {
636651
// releasing last bundle in workspace (special
637652
// case for sonatype release)
638-
logger.info("Last release bundle {}", jar.getName());
653+
tt.getLogger()
654+
.lifecycle("bnd: Last release bundle ({}) {}", count, jar.getName());
639655
bndProject.release(new ReleaseParameter(null, false, true));
640656
}
641657
} catch (Exception e) {

gradle-plugins/biz.aQute.bnd.gradle/src/main/java/aQute/bnd/gradle/ReleaseCounterService.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ public abstract class ReleaseCounterService
1313

1414
private final AtomicInteger remaining = new AtomicInteger(0);
1515

16+
/**
17+
* Default public constructor.
18+
*/
19+
public ReleaseCounterService() {}
20+
1621
public void setInitialCount(int n) {
1722
remaining.set(n);
1823
}
@@ -27,6 +32,13 @@ public boolean isLastReleaseTask() {
2732
return remaining.decrementAndGet() == 0;
2833
}
2934

35+
/**
36+
* @return the current count of remaining.
37+
*/
38+
public int getRemaining() {
39+
return remaining.get();
40+
}
41+
3042
@Override
3143
public void close() {
3244
// nothing

0 commit comments

Comments
 (0)