-
Notifications
You must be signed in to change notification settings - Fork 403
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[bug] close #82 - merge shadowJar manifest using jar.manifest as parent.
- Loading branch information
1 parent
2741143
commit bb8ccd8
Showing
6 changed files
with
215 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
...ain/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/DefaultInheritManifest.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package com.github.jengelman.gradle.plugins.shadow.tasks | ||
|
||
import org.gradle.api.internal.file.FileResolver | ||
import org.gradle.api.java.archives.internal.DefaultManifest | ||
import org.gradle.api.java.archives.internal.DefaultManifestMergeSpec | ||
import org.gradle.util.ConfigureUtil | ||
|
||
class DefaultInheritManifest extends DefaultManifest implements InheritManifest { | ||
|
||
private List<DefaultManifestMergeSpec> inheritMergeSpecs = [] | ||
|
||
private final FileResolver fileResolver | ||
|
||
DefaultInheritManifest(FileResolver fileResolver) { | ||
super(fileResolver) | ||
this.fileResolver = fileResolver | ||
} | ||
|
||
public InheritManifest inheritFrom(Object... inheritPaths) { | ||
inheritFrom(inheritPaths, null) | ||
return this | ||
} | ||
|
||
public InheritManifest inheritFrom(Object inheritPaths, Closure closure) { | ||
DefaultManifestMergeSpec mergeSpec = new DefaultManifestMergeSpec() | ||
mergeSpec.from(inheritPaths) | ||
inheritMergeSpecs.add(mergeSpec) | ||
ConfigureUtil.configure(closure, mergeSpec) | ||
return this | ||
} | ||
|
||
@Override | ||
public DefaultManifest getEffectiveManifest() { | ||
DefaultManifest base = new DefaultManifest(fileResolver) | ||
inheritMergeSpecs.each { | ||
base = it.merge(base, fileResolver) | ||
} | ||
base.from this.asDefaultManifest() | ||
return base.getEffectiveManifest() | ||
} | ||
|
||
private DefaultManifest asDefaultManifest() { | ||
DefaultManifest newManifest = new DefaultManifest(fileResolver) | ||
newManifest.attributes this.attributes | ||
this.sections.each { section, attrs -> | ||
newManifest.attributes attrs, section | ||
} | ||
newManifest.mergeSpecs.addAll(this.mergeSpecs) | ||
return newManifest | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/main/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/InheritManifest.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.github.jengelman.gradle.plugins.shadow.tasks | ||
|
||
import org.gradle.api.java.archives.Manifest | ||
|
||
public interface InheritManifest extends Manifest { | ||
|
||
InheritManifest inheritFrom(Object... inheritPaths) | ||
|
||
InheritManifest inheritFrom(Object inheritPaths, Closure closure) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters