Skip to content

Commit

Permalink
Ensure implementation and specification entries are present in `MANIF…
Browse files Browse the repository at this point in the history
…EST.MF`
  • Loading branch information
basil committed Nov 26, 2021
1 parent bcc4f2c commit 8681124
Showing 1 changed file with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import org.apache.maven.archiver.MavenArchiver;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.DependencyResolutionRequiredException;
import org.apache.maven.artifact.versioning.ArtifactVersion;
import org.apache.maven.artifact.versioning.OverConstrainedVersionException;
import org.apache.maven.model.Developer;
import org.apache.maven.model.License;
import org.apache.maven.model.Scm;
Expand Down Expand Up @@ -109,6 +111,34 @@ protected void setAttributes(Manifest.ExistingSection mainSection) throws MojoEx

mainSection.addAttributeAndCheck(new Manifest.Attribute("Plugin-Class",pluginClassName));
}

mainSection.addAttributeAndCheck(
new Manifest.Attribute("Extension-Name", project.getArtifactId()));
mainSection.addAttributeAndCheck(
new Manifest.Attribute("Implementation-Title", project.getArtifactId()));
mainSection.addAttributeAndCheck(
new Manifest.Attribute("Implementation-Version", project.getVersion()));
if (project.getOrganization() != null) {
mainSection.addAttributeAndCheck(
new Manifest.Attribute("Implementation-Vendor", project.getOrganization().getName()));
}
mainSection.addAttributeAndCheck(
new Manifest.Attribute("Specification-Title", project.getDescription()));
try {
ArtifactVersion version = project.getArtifact().getSelectedVersion();
String specVersion =
String.format("%s.%s", version.getMajorVersion(), version.getMinorVersion());
mainSection.addAttributeAndCheck(
new Manifest.Attribute("Specification-Version", specVersion));
} catch (OverConstrainedVersionException e) {
throw new ManifestException(
"Failed to get selected artifact version to calculate the specification version: " + e.getMessage());
}
if (project.getOrganization() != null) {
mainSection.addAttributeAndCheck(
new Manifest.Attribute("Specification-Vendor", project.getOrganization().getName()));
}

mainSection.addAttributeAndCheck(new Manifest.Attribute("Group-Id",project.getGroupId()));
mainSection.addAttributeAndCheck(new Manifest.Attribute("Short-Name",project.getArtifactId()));
mainSection.addAttributeAndCheck(new Manifest.Attribute("Long-Name",pluginName));
Expand Down

0 comments on commit 8681124

Please sign in to comment.