Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
105 additions
and
83 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
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
44 changes: 44 additions & 0 deletions
44
src/main/java/com/cloudbees/maven/license/LicenseScript.java
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,44 @@ | ||
package com.cloudbees.maven.license; | ||
|
||
import groovy.lang.Binding; | ||
import groovy.lang.Closure; | ||
import groovy.lang.Script; | ||
import org.apache.maven.project.MavenProject; | ||
|
||
/** | ||
* @author Kohsuke Kawaguchi | ||
*/ | ||
public abstract class LicenseScript extends Script { | ||
public MavenProject project; | ||
Closure completer; | ||
Closure generator; | ||
|
||
public LicenseScript() { | ||
} | ||
|
||
public LicenseScript(Binding binding) { | ||
super(binding); | ||
} | ||
|
||
public void complete(Closure closure) { | ||
this.completer = closure; | ||
} | ||
|
||
public void generate(Closure closure) { | ||
this.generator = closure; | ||
} | ||
|
||
public void runCompleter(CompleterDelegate delegate) { | ||
if (completer!=null) { | ||
completer.setDelegate(delegate); | ||
completer.run(); | ||
} | ||
} | ||
|
||
public void runGenerator(GeneratorDelegate delegate) { | ||
if (generator!=null) { | ||
generator.setDelegate(delegate); | ||
generator.run(); | ||
} | ||
} | ||
} |
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
24 changes: 13 additions & 11 deletions
24
src/main/resources/com/cloudbees/maven/license/xmlgen.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 |
---|---|---|
@@ -1,19 +1,21 @@ | ||
import groovy.xml.MarkupBuilder; | ||
|
||
mojo.generateLicenseXml.parentFile?.mkdirs() | ||
mojo.generateLicenseXml.withWriter { w -> | ||
def xml = new MarkupBuilder(w) | ||
xml.omitNullAttributes = true; | ||
generate { | ||
mojo.generateLicenseXml.parentFile?.mkdirs() | ||
mojo.generateLicenseXml.withWriter { w -> | ||
def xml = new MarkupBuilder(w) | ||
xml.omitNullAttributes = true; | ||
|
||
xml.'l:dependencies'('xmlns:l':'licenses') { | ||
dependencies.each { d -> | ||
'l:dependency'(name:d.name, groupId:d.groupId, artifactId:d.artifactId, version:d.version, url:d.url) { | ||
'l:description'(d.description) | ||
d.licenses.each { l -> | ||
'l:license'(name:l.name, url:l.url) | ||
xml.'l:dependencies'('xmlns:l':'licenses') { | ||
dependencies.each { d -> | ||
'l:dependency'(name:d.name, groupId:d.groupId, artifactId:d.artifactId, version:d.version, url:d.url) { | ||
'l:description'(d.description) | ||
d.licenses.each { l -> | ||
'l:license'(name:l.name, url:l.url) | ||
} | ||
} | ||
} | ||
} | ||
log.info("Generated ${mojo.generateLicenseXml}") | ||
} | ||
log.info("Generated ${mojo.generateLicenseXml}") | ||
} |