[java-mvn-enforcer] branch main updated: JMVN-37 JMVN-31 Change parent pomn to be java-parent

Rod Widdowson rdw at steadingsoftware.com
Sat Apr 30 12:50:10 UTC 2022


This is an automated email from the git hooks/post-receive script.

rdw pushed a commit to branch main
in repository java-mvn-enforcer.

View the commit online:
http://git.shibboleth.net/view/?p=java-mvn-enforcer.git;a=commit;h=2745f22c5dbda890c40c64a38ac16e207d3b5ce5

The following commit(s) were added to refs/heads/main by this push:
     new 2745f22  JMVN-37 JMVN-31 Change parent pomn to be java-parent
2745f22 is described below

commit 2745f22c5dbda890c40c64a38ac16e207d3b5ce5
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Sat Apr 30 13:47:00 2022 +0100

    JMVN-37 JMVN-31 Change parent pomn to be java-parent
    
    https://shibboleth.atlassian.net/browse/JMVN-31
    https://shibboleth.atlassian.net/browse/JMVN-37
    
    Clean up over-zealous pom clean up.  At the same time
    removed a dead module.
---
 pom.xml                                            |   6 +-
 .../shibboleth/mvn/enforcer/impl/HTTPLoader.java   | 128 ---------------------
 2 files changed, 5 insertions(+), 129 deletions(-)

diff --git a/pom.xml b/pom.xml
index 6d0d867..660ebd0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -94,7 +94,11 @@
             <!-- Required for command line classes. -->
             <scope>test</scope>
         </dependency>
-
+	<dependency>
+            <groupId>org.apache.maven.shared</groupId>
+            <artifactId>maven-invoker</artifactId>
+            <version>3.1.0</version>
+        </dependency>
         <!--  Provided because we are inside maven  -->
          <dependency>
             <groupId>org.apache.maven.plugins</groupId>
diff --git a/src/main/java/net/shibboleth/mvn/enforcer/impl/HTTPLoader.java b/src/main/java/net/shibboleth/mvn/enforcer/impl/HTTPLoader.java
deleted file mode 100644
index 8154673..0000000
--- a/src/main/java/net/shibboleth/mvn/enforcer/impl/HTTPLoader.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Licensed to the University Corporation for Advanced Internet Development,
- * Inc. (UCAID) under one or more contributor license agreements.  See the
- * NOTICE file distributed with this work for additional information regarding
- * copyright ownership. The UCAID 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.
- */
-package net.shibboleth.mvn.enforcer.impl;
-
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.nio.file.Path;
-import java.time.Duration;
-import java.util.Arrays;
-import java.util.Properties;
-
-import javax.annotation.Nonnull;
-
-import org.apache.http.client.HttpClient;
-import org.apache.maven.shared.invoker.DefaultInvocationRequest;
-import org.apache.maven.shared.invoker.DefaultInvoker;
-import org.apache.maven.shared.invoker.InvocationRequest;
-import org.apache.maven.shared.invoker.Invoker;
-
-import net.shibboleth.ext.spring.resource.HTTPResource;
-import net.shibboleth.mvn.enforcer.impl.ParsedPom.PomArtifact;
-import net.shibboleth.utilities.java.support.httpclient.HttpClientBuilder;
-
-/** Class do the {@link MavenLoader} think with http. */
-public class HTTPLoader  implements MavenLoader {
-
-    /** Http Client. */
-    private final HttpClient httpClient;
-    
-    /** Where to put stuff. */
-    private final Path workingDir;
-    
-    /** Constructor.
-     * @param tmpDir working dir (shared with the enforcer)
-     * @throws Exception on error
-     */
-    public HTTPLoader(final Path tmpDir) throws Exception {
-        final HttpClientBuilder builder = new HttpClientBuilder();
-        builder.setConnectionTimeout(Duration.ofSeconds(5));
-        httpClient = builder.buildClient();
-        workingDir = tmpDir;
-    }
-        
-    /**
-     * Get the base URL in Maven for the artifact.
-     * @param artifact the input.
-     * @return the address in nexus.
-     */
-    @Nonnull private String baseURLfor(@Nonnull final PomArtifact artifact) {
-        if (artifact.getGroupId().startsWith("net.shibboleth") || artifact.getGroupId().startsWith("org.opensaml")) {
-            return "https://build.shibboleth.net/nexus/service/local/repositories/releases/content/";
-        }
-        return "https://build.shibboleth.net/nexus/service/local/repositories/thirdparty/content/";
-    }
-
-        
-    /** Tell Maven to download the POM for artifact and returns it's path.
-     * @param artifact what to look for
-     * @param type the type to dowb load ('pom' or 'jar.asc' and so on
-     * @return the pom as a {@link Path}
-     * @throws Exception from the copy
-     */
-    @Override
-    public Path downloadArtifact(final PomArtifact artifact, final String type) throws Exception {
-        final Path path = workingDir.resolve(artifact.getArtifactId() + "." + type);
-        final File output =  path.toFile();
-        
-        if (artifact.getVersion().endsWith("SNAPSHOT")) {
-            // Gotta use maven...
-            final String fullArtifactName = new StringBuilder(artifact.getGroupId())
-                .append(':')
-                .append(artifact.getArtifactId())
-                .append(':')
-                .append(artifact.getVersion())
-                .append(':')
-                .append(type)
-                .toString();
-            final Properties props = new Properties(3);
-            props.setProperty("artifact",fullArtifactName);
-            props.setProperty("mdep.stripVersion","true");
-            props.setProperty("outputDirectory", workingDir.toString());
-
-            final InvocationRequest request = new DefaultInvocationRequest().
-                    setProperties(props).
-                    setGoals( Arrays.asList( "dependency:copy"));
-            final Invoker invoker = new DefaultInvoker();
-            invoker.execute( request );
-        } else {
-            final String fullAddress = new StringBuilder(baseURLfor(artifact))
-                .append(artifact.getGroupId().replaceAll("\\.", "/"))
-                .append('/')
-                .append(artifact.getArtifactId())
-                .append('/')
-                .append(artifact.getVersion())
-                .append('/')
-                .append(artifact.getArtifactId())
-                .append('-')
-                .append(artifact.getVersion())
-                .append('.')
-                .append(type)
-                .toString();
-            final HTTPResource inResource = new HTTPResource(httpClient, fullAddress);
-
-            try (final OutputStream outputStream = new BufferedOutputStream(new FileOutputStream(output));
-                 final InputStream inStream = inResource.getInputStream()) {
-                inStream.transferTo(outputStream);
-            }
-        }
-        return path;
-    }
-}

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list