Skip to content

Commit

Permalink
Upgrade groovy
Browse files Browse the repository at this point in the history
  • Loading branch information
timja committed Jan 26, 2021
1 parent 199e46e commit b82ab21
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 18 deletions.
105 changes: 97 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.sonatype.oss</groupId>
<artifactId>oss-parent</artifactId>
<version>7</version>
<groupId>org.jenkins-ci</groupId>
<artifactId>jenkins</artifactId>
<version>1.62</version>
<relativePath />
</parent>

<groupId>com.cloudbees</groupId>
Expand All @@ -13,17 +14,20 @@
<packaging>maven-plugin</packaging>

<name>maven-license-plugin Maven Plugin</name>
<url>http://maven.apache.org</url>
<url>https://maven.apache.org</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<sonatypeOssDistMgmtSnapshotsUrl>https://oss.sonatype.org/content/repositories/snapshots/</sonatypeOssDistMgmtSnapshotsUrl>
<arguments />
<!-- Need to rewrite plugin to use annotations rather than javadoc in property binding for a few of the remaining issues -->
<spotbugs.threshold>High</spotbugs.threshold>
</properties>

<scm>
<connection>scm:git:[email protected]:cloudbees/maven-license-plugin.git</connection>
<developerConnection>scm:git:[email protected]:cloudbees/maven-license-plugin.git</developerConnection>
</scm>


<dependencies>
<dependency>
Expand All @@ -34,7 +38,6 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
Expand All @@ -44,11 +47,88 @@
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy</artifactId>
<version>1.6.5</version>
<artifactId>groovy-xml</artifactId>
<version>3.0.7</version>
</dependency>
</dependencies>

<repositories>
<repository>
<id>sonatype-nexus-snapshots</id>
<name>Sonatype Nexus Snapshots</name>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>


<distributionManagement>
<snapshotRepository>
<id>sonatype-nexus-snapshots</id>
<name>Sonatype Nexus Snapshots</name>
<url>${sonatypeOssDistMgmtSnapshotsUrl}</url>
</snapshotRepository>
<repository>
<id>sonatype-nexus-staging</id>
<name>Nexus Release Repository</name>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>

<profiles>
<profile>
<id>sonatype-oss-release</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>


<build>
<plugins>
<plugin>
Expand All @@ -67,6 +147,15 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<configuration>
<mavenExecutorId>forked-path</mavenExecutorId>
<useReleaseProfile>false</useReleaseProfile>
<arguments>${arguments} -Psonatype-oss-release</arguments>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ public void accept(String name) {
return;
}
}
IllegalStateException error = new IllegalStateException("Expecting " + name + " but found " + toString(licenses) + " for dependency " + toString(dependency));
}

private String toString(Collection<License> lics) {
Expand Down
26 changes: 17 additions & 9 deletions src/main/java/com/cloudbees/maven/license/ProcessMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,15 @@

import java.io.File;
import java.io.IOException;
import java.io.StringReader;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.Set;

/**
Expand Down Expand Up @@ -146,11 +149,20 @@ public void execute() throws MojoExecutionException {
}
}

if (generateLicenseXml!=null)
comp.add((LicenseScript) shell.parse(getClass().getResourceAsStream("xmlgen.groovy"),"xmlgen.groovy"));
if (generateLicenseXml!=null) {
try {
comp.add((LicenseScript) shell.parse(getClass().getResource("xmlgen.groovy").toURI()));
} catch (URISyntaxException | IOException e) {
throw new MojoExecutionException("Failed to retrieve xmlgen.groovy",e);
}
}

if (generateLicenseHtml!=null)
comp.add((LicenseScript) shell.parse(getClass().getResourceAsStream("htmlgen.groovy"),"htmlgen.groovy"));
try {
comp.add((LicenseScript) shell.parse(getClass().getResource("htmlgen.groovy").toURI()));
} catch (URISyntaxException | IOException e) {
throw new MojoExecutionException("Failed to retrieve htmlgen.groovy", e);
}

if (inlineScript!=null)
comp.add((LicenseScript)shell.parse(inlineScript,"inlineScript"));
Expand Down Expand Up @@ -186,11 +198,7 @@ public void execute() throws MojoExecutionException {
}

// filter out optional components
for (Iterator<Entry<Artifact, MavenProject>> itr = models.entrySet().iterator(); itr.hasNext();) {
Entry<Artifact, MavenProject> e = itr.next();
if (e.getKey().isOptional())
itr.remove();
}
models.entrySet().removeIf(e -> e.getKey().isOptional());

for (MavenProject e : models.values()) {
// let the completion script intercept and process the licenses
Expand Down Expand Up @@ -237,7 +245,7 @@ private List<LicenseScript> parseScripts(File src, GroovyShell shell) throws Moj
if (src !=null) {
try {
if (src.isDirectory()) {
for (File script : src.listFiles())
for (File script : Objects.requireNonNull(src.listFiles()))
comp.add((LicenseScript)shell.parse(script));
} else {
comp.add((LicenseScript)shell.parse(src));
Expand Down

0 comments on commit b82ab21

Please sign in to comment.