You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by cs...@apache.org on 2022/03/15 13:57:27 UTC

[maven-resolver] branch MRESOLVER-236-resolver-signature created (now 8be9717)

This is an automated email from the ASF dual-hosted git repository.

cstamas pushed a change to branch MRESOLVER-236-resolver-signature
in repository https://gitbox.apache.org/repos/asf/maven-resolver.git.


      at 8be9717  [MRESOLVER-236] Add demo doing signsture resolution

This branch includes the following new commits:

     new 8be9717  [MRESOLVER-236] Add demo doing signsture resolution

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


[maven-resolver] 01/01: [MRESOLVER-236] Add demo doing signsture resolution

Posted by cs...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

cstamas pushed a commit to branch MRESOLVER-236-resolver-signature
in repository https://gitbox.apache.org/repos/asf/maven-resolver.git

commit 8be97171e5a0cf13d0172ec4116fb047f9bd7995
Author: Tamas Cservenak <ta...@cservenak.net>
AuthorDate: Tue Mar 15 14:56:26 2022 +0100

    [MRESOLVER-236] Add demo doing signsture resolution
    
    And use FAIL checksum policy. This should prove that resolving classic
    GPG (or any other) signature is now possible.
---
 .../maven/resolver/examples/AllResolverDemos.java  |  1 +
 .../examples/ResolveArtifactSignature.java         | 66 ++++++++++++++++++++++
 2 files changed, 67 insertions(+)

diff --git a/maven-resolver-demos/maven-resolver-demo-snippets/src/main/java/org/apache/maven/resolver/examples/AllResolverDemos.java b/maven-resolver-demos/maven-resolver-demo-snippets/src/main/java/org/apache/maven/resolver/examples/AllResolverDemos.java
index 74bb3d4..6b2fadc 100644
--- a/maven-resolver-demos/maven-resolver-demo-snippets/src/main/java/org/apache/maven/resolver/examples/AllResolverDemos.java
+++ b/maven-resolver-demos/maven-resolver-demo-snippets/src/main/java/org/apache/maven/resolver/examples/AllResolverDemos.java
@@ -38,6 +38,7 @@ public class AllResolverDemos
         GetDependencyTree.main( args );
         GetDependencyHierarchy.main( args );
         ResolveArtifact.main( args );
+        ResolveArtifactSignature.main( args );
         ResolveTransitiveDependencies.main( args );
         InstallArtifacts.main( args );
         DeployArtifacts.main( args );
diff --git a/maven-resolver-demos/maven-resolver-demo-snippets/src/main/java/org/apache/maven/resolver/examples/ResolveArtifactSignature.java b/maven-resolver-demos/maven-resolver-demo-snippets/src/main/java/org/apache/maven/resolver/examples/ResolveArtifactSignature.java
new file mode 100644
index 0000000..9928945
--- /dev/null
+++ b/maven-resolver-demos/maven-resolver-demo-snippets/src/main/java/org/apache/maven/resolver/examples/ResolveArtifactSignature.java
@@ -0,0 +1,66 @@
+package org.apache.maven.resolver.examples;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.resolver.examples.util.Booter;
+import org.eclipse.aether.DefaultRepositorySystemSession;
+import org.eclipse.aether.RepositorySystem;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.artifact.DefaultArtifact;
+import org.eclipse.aether.repository.RepositoryPolicy;
+import org.eclipse.aether.resolution.ArtifactRequest;
+import org.eclipse.aether.resolution.ArtifactResult;
+
+/**
+ * Resolves a single artifact's signature.
+ */
+public class ResolveArtifactSignature
+{
+
+    /**
+     * Main.
+     * @param args
+     * @throws Exception
+     */
+    public static void main( String[] args )
+        throws Exception
+    {
+        System.out.println( "------------------------------------------------------------" );
+        System.out.println( ResolveArtifactSignature.class.getSimpleName() );
+
+        RepositorySystem system = Booter.newRepositorySystem( Booter.selectFactory( args ) );
+
+        DefaultRepositorySystemSession session = Booter.newRepositorySystemSession( system );
+        session.setChecksumPolicy( RepositoryPolicy.CHECKSUM_POLICY_FAIL );
+
+        Artifact artifact = new DefaultArtifact( "org.apache.maven.resolver:maven-resolver-util:jar.asc:1.3.3" );
+
+        ArtifactRequest artifactRequest = new ArtifactRequest();
+        artifactRequest.setArtifact( artifact );
+        artifactRequest.setRepositories( Booter.newRepositories( system, session ) );
+
+        ArtifactResult artifactResult = system.resolveArtifact( session, artifactRequest );
+
+        artifact = artifactResult.getArtifact();
+
+        System.out.println( artifact + " resolved to  " + artifact.getFile() );
+    }
+
+}