Skip to content

Commit 518f7ab

Browse files
committed
remove excess manifest attributes
* Bundle-ClassPath * DynamicImport-Package * Eclipse-BuddyPolicy * Eclipse-ExtensibleAPI * Extension-Name
1 parent c471e5d commit 518f7ab

File tree

5 files changed

+82
-93
lines changed

5 files changed

+82
-93
lines changed

build-logic/src/main/groovy/org.apache.groovy-base.gradle

+35-34
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,16 @@ if (sharedConfiguration.hasCodeCoverage.get()) {
4747
pluginManager.apply(JacocoPlugin)
4848
}
4949

50-
def groovyLibrary = project.extensions.create("groovyLibrary", GroovyLibraryExtension, sharedConfiguration, java)
50+
def groovyLibrary = project.extensions.create('groovyLibrary', GroovyLibraryExtension, sharedConfiguration, java)
5151

5252
java {
5353
withSourcesJar()
5454
withJavadocJar()
5555
}
5656

57-
def generateReleaseInfo = tasks.register("generateReleaseInfo", ReleaseInfoGenerator)
57+
def generateReleaseInfo = tasks.register('generateReleaseInfo', ReleaseInfoGenerator)
5858

59-
def groovydocJar = tasks.register("groovydocJar", Jar) {
59+
def groovydocJar = tasks.register('groovydocJar', Jar) {
6060
from groovydoc
6161
archiveClassifier = 'groovydoc'
6262
group = 'build'
@@ -70,7 +70,7 @@ configurations {
7070
attributes {
7171
attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category, Category.DOCUMENTATION))
7272
attribute(Bundling.BUNDLING_ATTRIBUTE, objects.named(Bundling, Bundling.EXTERNAL))
73-
attribute(DocsType.DOCS_TYPE_ATTRIBUTE, objects.named(DocsType, "groovydoc"))
73+
attribute(DocsType.DOCS_TYPE_ATTRIBUTE, objects.named(DocsType, 'groovydoc'))
7474
attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage, Usage.JAVA_RUNTIME))
7575
}
7676
outgoing {
@@ -86,7 +86,7 @@ configurations {
8686
attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category, Category.DOCUMENTATION))
8787
attribute(Bundling.BUNDLING_ATTRIBUTE, objects.named(Bundling, Bundling.EXTERNAL))
8888
attribute(DocsType.DOCS_TYPE_ATTRIBUTE, objects.named(DocsType, DocsType.SOURCES))
89-
attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage, "aggregation"))
89+
attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage, 'aggregation'))
9090
}
9191
outgoing {
9292
sourceSets.main.java.srcDirs.each {
@@ -104,20 +104,20 @@ configurations {
104104
attributes {
105105
attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category, Category.LIBRARY))
106106
attribute(Bundling.BUNDLING_ATTRIBUTE, objects.named(Bundling, Bundling.EXTERNAL))
107-
attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage, "javadocClasspath"))
107+
attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage, 'javadocClasspath'))
108108
}
109109
outgoing {
110110
artifact tasks.named('jar')
111111
}
112112
}
113113
codenarc {
114114
resolutionStrategy.dependencySubstitution {
115-
substitute module("org.codehaus.groovy:groovy") using project(":")
116-
substitute module("org.codehaus.groovy:groovy-ant") using project(":groovy-ant")
117-
substitute module("org.codehaus.groovy:groovy-templates") using project(":groovy-templates")
118-
substitute module("org.codehaus.groovy:groovy-xml") using project(":groovy-xml")
119-
substitute module("org.codehaus.groovy:groovy-json") using project(":groovy-json")
120-
substitute module("org.codehaus.groovy:groovy-groovydoc") using project(":groovy-groovydoc")
115+
substitute module('org.codehaus.groovy:groovy') using project(':')
116+
substitute module('org.codehaus.groovy:groovy-ant') using project(':groovy-ant')
117+
substitute module('org.codehaus.groovy:groovy-xml') using project(':groovy-xml')
118+
substitute module('org.codehaus.groovy:groovy-json') using project(':groovy-json')
119+
substitute module('org.codehaus.groovy:groovy-groovydoc') using project(':groovy-groovydoc')
120+
substitute module('org.codehaus.groovy:groovy-templates') using project(':groovy-templates')
121121
}
122122

123123
exclude module: 'groovy-all'
@@ -128,7 +128,7 @@ dependencies {
128128
compileOnly providers.provider { "com.github.spotbugs:spotbugs-annotations:${versions.spotbugs}" }
129129

130130
codenarc "org.codenarc:CodeNarc:${versions.codenarc}"
131-
codenarc project(":groovy-templates")
131+
codenarc project(':groovy-templates')
132132

133133
checkstyle "com.puppycrawl.tools:checkstyle:${versions.checkstyle}"
134134
spotbugs "com.github.spotbugs:spotbugs:${versions.spotbugs}"
@@ -138,15 +138,16 @@ dependencies {
138138
}
139139

140140
def excludedFromManifest = [
141-
'Ant-Version',
142-
'Originally-Created-By',
143-
'Bnd-LastModified',
144-
'Created-By'
141+
'Ant-Version',
142+
'Bnd-LastModified',
143+
'Created-By',
144+
'Originally-Created-By',
145+
'Tool'
145146
]
146147

147148
tasks.named('jar') {
148149
archiveAppendix = 'raw'
149-
archiveClassifier.set("raw")
150+
archiveClassifier.set('raw')
150151
groovyLibrary.configureManifest(manifest, excludedFromManifest)
151152
}
152153

@@ -155,7 +156,7 @@ tasks.withType(AbstractArchiveTask).configureEach {
155156
reproducibleFileOrder = true
156157
}
157158

158-
tasks.withType(Jar).configureEach {jar ->
159+
tasks.withType(Jar).configureEach { jar ->
159160
metaInf {
160161
if (jar.name == 'sourcesJar') {
161162
if (file("${projectDir}/LICENSE").exists()) {
@@ -177,7 +178,7 @@ tasks.withType(Jar).configureEach {jar ->
177178
}
178179
}
179180

180-
tasks.register("jarjar", JarJarTask) {
181+
tasks.register('jarjar', JarJarTask) {
181182
from = jar.archiveFile
182183
repackagedLibraries.from configurations.runtimeClasspath.incoming.artifactView {
183184
componentFilter { component ->
@@ -208,9 +209,9 @@ tasks.register("jarjar", JarJarTask) {
208209
outputFile = tasks.named('jar').flatMap { layout.buildDirectory.file("libs/${it.archiveBaseName.get()}-${it.archiveVersion.get()}${(it.archiveClassifier.get() && it.archiveClassifier.get() != 'raw') ? '-' + it.archiveClassifier.get() : ''}.jar") }
209210

210211
withManifest {
211-
def extras = project.name == 'groovy' ? ['Main-Class': 'groovy.ui.GroovyMain'] : [:]
212-
def moduleName = "org.apache.${project.name.replace('-', '.')}"
213-
attributes('Automatic-Module-Name': moduleName, 'Bundle-Name': 'Groovy module: ' + project.name, *:extras)
212+
String projectName = project.name
213+
String autoModName = "org.apache.${projectName.replace('-','.')}"
214+
attributes('Automatic-Module-Name': autoModName, 'Bundle-Name': "Groovy module: $projectName")
214215
groovyLibrary.configureManifest(it, excludedFromManifest)
215216
classpath = configurations.runtimeClasspath
216217
}
@@ -225,17 +226,17 @@ tasks.withType(Javadoc).configureEach {
225226
options.source = sharedConfiguration.targetJavaVersion.get()
226227
}
227228

228-
tasks.named("compileTestGroovy") {
229-
options.forkOptions.jvmArgs += ["-Dspock.iKnowWhatImDoing.disableGroovyVersionCheck=true"]
229+
tasks.named('compileTestGroovy') {
230+
options.forkOptions.jvmArgs += ['-Dspock.iKnowWhatImDoing.disableGroovyVersionCheck=true']
230231
}
231232

232233
tasks.withType(CodeNarc).configureEach {
233234
ignoreFailures = true
234-
configFile = rootProject.file("config/codenarc/codenarc.groovy")
235+
configFile = rootProject.file('config/codenarc/codenarc.groovy')
235236
}
236237

237238
tasks.withType(SpotBugsTask).configureEach {
238-
excludeFilter = rootProject.file("config/spotbugs/exclude.xml")
239+
excludeFilter = rootProject.file('config/spotbugs/exclude.xml')
239240
ignoreFailures = true
240241
effort = Effort.valueOf('MAX')
241242
maxHeapSize = '2g'
@@ -250,14 +251,14 @@ tasks.withType(SpotBugsTask).configureEach {
250251
}
251252
}
252253

253-
tasks.register("checkstyle") {
254+
tasks.register('checkstyle') {
254255
dependsOn tasks.withType(Checkstyle)
255256
}
256257

257258
tasks.withType(Checkstyle).configureEach {chk ->
258259
showViolations = false
259260
ignoreFailures = true
260-
configFile = rootProject.file("config/checkstyle/checkstyle.xml")
261+
configFile = rootProject.file('config/checkstyle/checkstyle.xml')
261262
configProperties = ['rootProject.projectDir': rootProject.projectDir]
262263
def reportFile = layout.buildDirectory.file("reports/checkstyle/${name}.xml")
263264
reports {
@@ -271,7 +272,7 @@ tasks.withType(Checkstyle).configureEach {chk ->
271272
tasks.register("${name}Report", CheckstyleHtmlReport) {
272273
dependsOn chk
273274
source.from(chk.source)
274-
configFile = rootProject.file("config/checkstyle/checkstyle-report.groovy")
275+
configFile = rootProject.file('config/checkstyle/checkstyle-report.groovy')
275276
checkstyleReportFile = reportFile
276277
outputFile = layout.buildDirectory.file("reports/checkstyle/${chk.name}.html")
277278
}
@@ -280,8 +281,8 @@ tasks.withType(Checkstyle).configureEach {chk ->
280281

281282
// remove below if checkstyle fix up their dependency metadata to no longer have conflicts
282283
configurations.checkstyle {
283-
resolutionStrategy.capabilitiesResolution.withCapability("com.google.collections:google-collections") {
284-
select("com.google.guava:guava:0")
284+
resolutionStrategy.capabilitiesResolution.withCapability('com.google.collections:google-collections') {
285+
select('com.google.guava:guava:0')
285286
}
286287
}
287288

@@ -317,8 +318,8 @@ def shadowRuntime = createConsumableConfiguration(objects, tasks, configurations
317318
dependencies {
318319
// All Groovy modules depend on the Groovy BOM which itself has constraints on all
319320
// Groovy modules, which brings nice alignment features!
320-
groovyApiElements platform(project(":groovy-bom"))
321-
groovyRuntimeElements platform(project(":groovy-bom"))
321+
groovyApiElements platform(project(':groovy-bom'))
322+
groovyRuntimeElements platform(project(':groovy-bom'))
322323
}
323324
component.addVariantsFromConfiguration(shadowApi) {
324325

build-logic/src/main/groovy/org.apache.groovy-core.gradle

+5-7
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ sourceSets {
104104
}
105105
}
106106

107-
def dgmConverter = tasks.register("dgmConverter", DgmConverter) {
107+
def dgmConverter = tasks.register('dgmConverter', DgmConverter) {
108108
classpath.from files(compileJava, configurations.compileClasspath)
109109
sources.from('src/main').include('**/*GroovyMethods.java')
110110
}
@@ -117,24 +117,22 @@ tasks.named('jar') {
117117
from dgmConverter
118118
}
119119

120-
tasks.named('jarjar') { JarJarTask it ->
120+
tasks.named('jarjar') { JarJarTask jjt ->
121121
def groovyBundleVersion = sharedConfiguration.groovyBundleVersion.get()
122-
it.withManifest {
123-
version = groovyBundleVersion
122+
jjt.withManifest {
124123
instruction '-nouses', 'true'
125124
instruction 'Export-Package', "*;version=${groovyBundleVersion}"
126-
instruction 'Eclipse-ExtensibleAPI', 'true'
127125
}
128126
}
129127

130128
// Gradle classloading magic with Groovy will only work if it finds a *jar*
131129
// on classpath. This "bootstrap jar" contains the minimal compiler, without .groovy compiled files
132130

133-
def bootstrapJar = tasks.register("bootstrapJar", Jar) {
131+
def bootstrapJar = tasks.register('bootstrapJar', Jar) {
134132
from compileJava
135133
from dgmConverter
136134

137-
destinationDirectory = layout.buildDirectory.dir("bootstrap")
135+
destinationDirectory = layout.buildDirectory.dir('bootstrap')
138136
archiveClassifier = 'bootstrap'
139137
}
140138

build-logic/src/main/groovy/org.apache.groovy-library.gradle

+10-13
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
* specific language governing permissions and limitations
1717
* under the License.
1818
*/
19+
1920
import org.apache.groovy.gradle.JarJarTask
2021

2122
plugins {
@@ -29,23 +30,19 @@ dependencies {
2930
testImplementation testFixtures(project(":"))
3031
}
3132

32-
tasks.named('jarjar') { JarJarTask it ->
33+
tasks.named('jarjar') { JarJarTask jjt ->
3334
def groovyBundleVersion = sharedConfiguration.groovyBundleVersion.get()
34-
def symbolicName = project.name
35-
it.withManifest {
36-
version = groovyBundleVersion
35+
jjt.withManifest {
3736
instruction '-nouses', 'true'
3837
instruction 'Export-Package', "*;version=${groovyBundleVersion}"
39-
instruction 'Fragment-Host', 'groovy'
38+
instruction 'Fragment-Host', 'groovy' // GROOVY-9402, GROOVY-11570
4039
def folder = file("${projectDir}/src/main/resources/META-INF/services")
41-
if (folder.exists()) {
42-
if (folder.listFiles().count { it.name ==~ /^(?!(org.codehaus.groovy.transform.ASTTransformation)$).*$/ } > 0) {
43-
instruction 'Require-Capability', 'osgi.extender;filter:="(osgi.extender=osgi.serviceloader.registrar)"'
44-
instruction 'Require-Capability', 'osgi.extender;filter:="(osgi.extender=osgi.serviceloader.processor)"'
45-
folder.eachFileMatch(~/^(?!(org.codehaus.groovy.transform.ASTTransformation)$).*$/) {
46-
instruction 'Require-Capability', "osgi.serviceloader;filter:=\"(osgi.serviceloader=${it.name})\";cardinality:=multiple"
47-
instruction 'Provide-Capability', "osgi.serviceloader;osgi.serviceloader=\"${it.name}\""
48-
}
40+
if (folder.exists() && folder.listFiles().count { it.name ==~ /^(?!(org.codehaus.groovy.transform.ASTTransformation)$).*$/ } > 0) {
41+
instruction 'Require-Capability', 'osgi.extender;filter:="(osgi.extender=osgi.serviceloader.registrar)"'
42+
instruction 'Require-Capability', 'osgi.extender;filter:="(osgi.extender=osgi.serviceloader.processor)"'
43+
folder.eachFileMatch(~/^(?!(org.codehaus.groovy.transform.ASTTransformation)$).*$/) {
44+
instruction 'Require-Capability', "osgi.serviceloader;filter:=\"(osgi.serviceloader=${it.name})\";cardinality:=multiple"
45+
instruction 'Provide-Capability', "osgi.serviceloader;osgi.serviceloader=\"${it.name}\""
4946
}
5047
}
5148
}

build-logic/src/main/groovy/org/apache/groovy/gradle/GroovyLibraryExtension.groovy

+28-26
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ package org.apache.groovy.gradle
2020

2121
import groovy.transform.CompileStatic
2222
import org.gradle.api.Action
23+
import org.gradle.api.Project
2324
import org.gradle.api.Task
2425
import org.gradle.api.artifacts.Configuration
2526
import org.gradle.api.artifacts.ConfigurationContainer
@@ -60,20 +61,20 @@ class GroovyLibraryExtension {
6061
final JavaPluginExtension javaPluginExtension
6162
final SoftwareComponentContainer components
6263
final ConfigurationContainer configurations
63-
final TaskContainer tasks
64+
private final String projectName
6465
final ProjectLayout layout
66+
final TaskContainer tasks
6567

6668
@Inject
6769
GroovyLibraryExtension(ObjectFactory factory,
68-
ProjectLayout layout,
6970
SharedConfiguration sharedConfiguration,
7071
JavaPluginExtension javaPluginExtension,
7172
SoftwareComponentContainer components,
7273
ConfigurationContainer configurations,
74+
Project project, ProjectLayout layout,
7375
TaskContainer tasks
7476
) {
7577
this.objects = factory
76-
this.layout = layout
7778
this.sharedConfiguration = sharedConfiguration
7879
this.includeInGroovyAll = factory.property(Boolean).convention(true)
7980
this.grooid = factory.property(Boolean).convention(false)
@@ -82,6 +83,8 @@ class GroovyLibraryExtension {
8283
this.javaPluginExtension = javaPluginExtension
8384
this.components = components
8485
this.configurations = configurations
86+
this.projectName = project.name
87+
this.layout = layout
8588
this.tasks = tasks
8689
}
8790

@@ -192,7 +195,7 @@ class GroovyLibraryExtension {
192195
void configureManifest(Manifest manifest, List<String> exclusions) {
193196
manifest.from(createBaseManifest()) { ManifestMergeSpec spec ->
194197
spec.eachEntry { ManifestMergeDetails details ->
195-
if (exclusions.any { it == details.key }) {
198+
if (exclusions.contains(details.getKey())) {
196199
details.exclude()
197200
}
198201
}
@@ -201,37 +204,36 @@ class GroovyLibraryExtension {
201204

202205
private Manifest createBaseManifest() {
203206
def groovyBundleVersion = sharedConfiguration.groovyBundleVersion.get()
204-
javaPluginExtension.manifest { Manifest mn ->
205-
mn.attributes(
206-
'Extension-Name': 'groovy',
207-
'Specification-Title': 'Groovy: a powerful, multi-faceted language for the JVM',
208-
'Specification-Version': groovyBundleVersion,
209-
'Specification-Vendor': 'The Apache Software Foundation',
210-
'Implementation-Title': 'Groovy: a powerful, multi-faceted language for the JVM',
211-
'Implementation-Version': groovyBundleVersion,
212-
'Implementation-Vendor': 'The Apache Software Foundation',
213-
'Bundle-ManifestVersion': '2',
214-
'Bundle-Description': 'Groovy Runtime',
215-
'Bundle-License': 'Apache-2.0',
216-
'Bundle-Version': groovyBundleVersion,
217-
'Bundle-Vendor': 'The Apache Software Foundation',
218-
'Bundle-ClassPath': '.',
219-
'Eclipse-BuddyPolicy': 'dependent',
220-
'DynamicImport-Package': '*')
207+
javaPluginExtension.manifest {
208+
attributes(
209+
'Bundle-ManifestVersion': '2',
210+
'Bundle-Description' : 'Groovy Runtime',
211+
'Bundle-Vendor' : 'The Apache Software Foundation',
212+
'Bundle-Version' : groovyBundleVersion,
213+
'Bundle-License' : 'Apache-2.0',
214+
'Specification-Title' : 'Groovy: a powerful, multi-faceted language for the JVM',
215+
'Specification-Vendor' : 'The Apache Software Foundation',
216+
'Specification-Version' : groovyBundleVersion,
217+
'Implementation-Title' : 'Groovy: a powerful, multi-faceted language for the JVM',
218+
'Implementation-Vendor' : 'The Apache Software Foundation',
219+
'Implementation-Version': groovyBundleVersion
220+
)
221+
if (projectName == 'groovy') {
222+
attributes('Main-Class': 'groovy.ui.GroovyMain')
223+
}
221224
}
222-
223225
}
224226

225227
class ModuleDescriptorSpec {
226228
String extensionClasses = ''
227229
String staticExtensionClasses = ''
228230

229231
private void build() {
230-
def moduleDescriptor = tasks.register("moduleDescriptor", WriteExtensionDescriptorTask) {
231-
it.extensionClasses = extensionClasses
232-
it.staticExtensionClasses = staticExtensionClasses
232+
def moduleDescriptor = tasks.register('moduleDescriptor', WriteExtensionDescriptorTask) { t ->
233+
t.extensionClasses = extensionClasses
234+
t.staticExtensionClasses = staticExtensionClasses
233235
}
234-
tasks.named("processResources") { Task t ->
236+
tasks.named('processResources') { Task t ->
235237
t.dependsOn(moduleDescriptor)
236238
}
237239
}

0 commit comments

Comments
 (0)