Skip to content

Commit 50222d3

Browse files
authored
[MGPG-120] New mojo sign-deployed (#88)
New mojo, "sign-deployed" that is able to sign already deployed artifacts. Assuming there is no Maven project, hence mojo should not require project, just a list of artifacts. --- https://issues.apache.org/jira/browse/MGPG-120
1 parent a6c3a09 commit 50222d3

14 files changed

+413
-1
lines changed

pom.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,13 @@ under the License.
123123
<version>${resolverVersion}</version>
124124
<scope>provided</scope>
125125
</dependency>
126+
<dependency>
127+
<groupId>org.apache.maven.resolver</groupId>
128+
<artifactId>maven-resolver-util</artifactId>
129+
<version>${resolverVersion}</version>
130+
<!-- This is needed to be in compile to work with Maven pre 3.9 -->
131+
<scope>compile</scope>
132+
</dependency>
126133
<dependency>
127134
<groupId>org.apache.maven.plugin-tools</groupId>
128135
<artifactId>maven-plugin-annotations</artifactId>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:sign-deployed
19+
invoker.environmentVariables.MAVEN_GPG_PASSPHRASE = TEST
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<!--
4+
Licensed to the Apache Software Foundation (ASF) under one
5+
or more contributor license agreements. See the NOTICE file
6+
distributed with this work for additional information
7+
regarding copyright ownership. The ASF licenses this file
8+
to you under the Apache License, Version 2.0 (the
9+
"License"); you may not use this file except in compliance
10+
with the License. You may obtain a copy of the License at
11+
12+
http://www.apache.org/licenses/LICENSE-2.0
13+
14+
Unless required by applicable law or agreed to in writing,
15+
software distributed under the License is distributed on an
16+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17+
KIND, either express or implied. See the License for the
18+
specific language governing permissions and limitations
19+
under the License.
20+
-->
21+
22+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
23+
<modelVersion>4.0.0</modelVersion>
24+
25+
<groupId>org.apache.maven.its.gpg.sadfs</groupId>
26+
<artifactId>test</artifactId>
27+
<version>1.0</version>
28+
<packaging>jar</packaging>
29+
30+
<name>MGPG-12</name>
31+
<description>
32+
Tests the signing and deployment of a simple release JAR along with its POM.
33+
</description>
34+
</project>
Binary file not shown.
Binary file not shown.

src/it/sign-deployed/test.properties

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
url = file://remote-repo
19+
repositoryId = staging-1
20+
artifacts = org.foo:bar:pom:1.0,org.foo:bar:jar:1.0,org.foo:bar:zip:1.0,org.foo:bar:tar.gz:1.0,org.foo:bar:tar.gz:src:1.0

src/it/sign-deployed/verify.groovy

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
var artifactDir = new File(basedir, "remote-repo/org/foo/bar/1.0")
20+
21+
var expectedFiles = [
22+
"bar-1.0.jar.asc",
23+
"bar-1.0-sources.jar.asc",
24+
"bar-1.0-javadoc.jar.asc",
25+
"bar-1.0.pom.asc",
26+
"bar-1.0.zip.asc",
27+
"bar-1.0-src.tar.gz.asc",
28+
"bar-1.0.tar.gz.asc"
29+
]
30+
31+
for (String expectedFile : expectedFiles) {
32+
var file = new File(artifactDir, expectedFile)
33+
34+
println "Checking for existence of $file"
35+
36+
if (!file.isFile()) {
37+
throw new Exception("Missing file $file")
38+
}
39+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.apache.maven.plugins.gpg;
20+
21+
import java.io.IOException;
22+
import java.util.Collection;
23+
24+
import org.eclipse.aether.RepositorySystemSession;
25+
import org.eclipse.aether.artifact.Artifact;
26+
import org.eclipse.aether.repository.RemoteRepository;
27+
28+
/**
29+
* Artifact collector SPI, that collects artifacts in some way from given {@link RemoteRepository}.
30+
*
31+
* @since 3.2.3
32+
*/
33+
public interface ArtifactCollectorSPI {
34+
/**
35+
* Returns collected artifacts or {@code null} if collection was not possible for any reason.
36+
* <p>
37+
* Collector should collect only <em>relevant artifacts</em>, those that are subject to signing.
38+
*/
39+
Collection<Artifact> collectArtifacts(RepositorySystemSession session, RemoteRepository remoteRepository)
40+
throws IOException;
41+
}

src/main/java/org/apache/maven/plugins/gpg/SignAndDeployFileMojo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
import org.eclipse.aether.repository.RemoteRepository;
5959

6060
/**
61-
* Signs artifacts and installs the artifact in the remote repository.
61+
* Signs artifacts and deploys the artifacts and signatures in the remote repository.
6262
*
6363
* @author Daniel Kulp
6464
* @since 1.0-beta-4

0 commit comments

Comments
 (0)