|
52 | 52 | import org.apache.maven.plugin.AbstractMojo; |
53 | 53 | import org.apache.maven.plugin.MojoExecutionException; |
54 | 54 | import org.apache.maven.plugin.MojoFailureException; |
| 55 | +import org.apache.maven.plugin.descriptor.PluginDescriptor; |
55 | 56 | import org.apache.maven.plugins.annotations.LifecyclePhase; |
56 | 57 | import org.apache.maven.plugins.annotations.Mojo; |
57 | 58 | import org.apache.maven.plugins.annotations.Parameter; |
@@ -165,6 +166,12 @@ public class BuildAttestationMojo extends AbstractMojo { |
165 | 166 | */ |
166 | 167 | @Parameter(property = "commons.release.signAttestation", defaultValue = "true") |
167 | 168 | private boolean signAttestation; |
| 169 | + /** |
| 170 | + * Descriptor of this plugin; used to fill in {@code builder.id} with the plugin's own |
| 171 | + * Package URL so that consumers can resolve the exact code that produced the provenance. |
| 172 | + */ |
| 173 | + @Parameter(defaultValue = "${plugin}", readonly = true) |
| 174 | + private PluginDescriptor pluginDescriptor; |
168 | 175 | /** |
169 | 176 | * GPG signer used for signing; lazily initialized from plugin parameters when {@code null}. |
170 | 177 | */ |
@@ -225,8 +232,10 @@ public void execute() throws MojoFailureException, MojoExecutionException { |
225 | 232 | final BuildDefinition buildDefinition = new BuildDefinition() |
226 | 233 | .setExternalParameters(BuildDefinitions.externalParameters(session)) |
227 | 234 | .setResolvedDependencies(getBuildDependencies()); |
| 235 | + final String builderId = String.format("pkg:maven/%s/%s@%s", |
| 236 | + pluginDescriptor.getGroupId(), pluginDescriptor.getArtifactId(), pluginDescriptor.getVersion()); |
228 | 237 | final RunDetails runDetails = new RunDetails() |
229 | | - .setBuilder(new Builder()) |
| 238 | + .setBuilder(new Builder().setId(builderId)) |
230 | 239 | .setMetadata(getBuildMetadata()); |
231 | 240 | final Provenance provenance = new Provenance() |
232 | 241 | .setBuildDefinition(buildDefinition) |
@@ -451,6 +460,15 @@ void setSignAttestation(final boolean signAttestation) { |
451 | 460 | this.signAttestation = signAttestation; |
452 | 461 | } |
453 | 462 |
|
| 463 | + /** |
| 464 | + * Sets the plugin descriptor. Intended for testing. |
| 465 | + * |
| 466 | + * @param pluginDescriptor the plugin descriptor |
| 467 | + */ |
| 468 | + void setPluginDescriptor(final PluginDescriptor pluginDescriptor) { |
| 469 | + this.pluginDescriptor = pluginDescriptor; |
| 470 | + } |
| 471 | + |
454 | 472 | /** |
455 | 473 | * Sets the GPG signer used for signing. Intended for testing. |
456 | 474 | * |
|
0 commit comments