Skip to content

Commit

Permalink
Use java to download external dependecies
Browse files Browse the repository at this point in the history
  • Loading branch information
Reamer committed Mar 28, 2024
1 parent a591523 commit 27dfd71
Show file tree
Hide file tree
Showing 19 changed files with 787 additions and 250 deletions.
52 changes: 49 additions & 3 deletions build-tools/pom.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<!--
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<!--
~ 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.
Expand All @@ -24,4 +26,48 @@
<artifactId>zeppelin</artifactId>
<version>0.12.0-SNAPSHOT</version>
</parent>
</project>
<properties>
<progressbar.version>0.9.5</progressbar.version>
</properties>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
<version>${commons.compress.version}</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</dependency>
<dependency>
<groupId>me.tongfei</groupId>
<artifactId>progressbar</artifactId>
<version>${progressbar.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>${log4j2.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*
* 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.
*/

package org.apache.zeppelin.build.tools;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.Optional;

public class DownloadRequest {
private final URL url;
private final Optional<URL> alternativeUrl;
private final int retries;

public static final int DEFAULT_RETRIES = 3;

public DownloadRequest(String url, int retries) throws MalformedURLException {
this(url, null, retries);
}

public DownloadRequest(String url, String alternativeUrl) throws MalformedURLException {
this(url, alternativeUrl, DEFAULT_RETRIES);
}

public DownloadRequest(String url, String alternativeUrl, int retries)
throws MalformedURLException {
if (alternativeUrl != null) {
this.url = new URL(url);
this.alternativeUrl = Optional.of(new URL(alternativeUrl));
this.retries = retries;
} else {
this.url = new URL(url);
this.alternativeUrl = Optional.empty();
this.retries = retries;
}
}

public DownloadRequest(URL url, int retries) {
this(url, null, retries);
}

public DownloadRequest(URL url, URL alternativeUrl) {
this(url, alternativeUrl, DEFAULT_RETRIES);
}

public DownloadRequest(URL url, URL alternativeUrl, int retries) {
this.url = url;
this.alternativeUrl = Optional.of(alternativeUrl);
this.retries = retries;
}

public URL getUrl() {
return url;
}

public Optional<URL> getAlternativeUrl() {
return alternativeUrl;
}

public int getRetries() {
return retries;
}
}
Loading

0 comments on commit 27dfd71

Please sign in to comment.