You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@netbeans.apache.org by GitBox <gi...@apache.org> on 2017/12/16 09:27:58 UTC

[GitHub] vieiro closed pull request #204: Multiple maven repository support

vieiro closed pull request #204: Multiple maven repository support 
URL: https://github.com/apache/incubator-netbeans/pull/204
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/nbbuild/antsrc/org/netbeans/nbbuild/extlibs/DownloadBinaries.java b/nbbuild/antsrc/org/netbeans/nbbuild/extlibs/DownloadBinaries.java
index 776fe9267..3e73f5d40 100644
--- a/nbbuild/antsrc/org/netbeans/nbbuild/extlibs/DownloadBinaries.java
+++ b/nbbuild/antsrc/org/netbeans/nbbuild/extlibs/DownloadBinaries.java
@@ -24,6 +24,7 @@
 import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.FileInputStream;
+import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
@@ -177,7 +178,27 @@ public void execute() throws BuildException {
             url = "http://central.maven.org/maven2/" + cacheName;
         }
         URL u = new URL(url);
-        return downloadFromServer(u);
+        try {
+            return downloadFromServer(u);
+        } catch (FileNotFoundException notInMavenCentral) {
+            /* File was not found in Maven central, let's try alternate repositories from the 'binaries.repositories' property */
+            String alternateRepositoriesProperty = getProject().getProperty("binaries.repositories");
+            if (alternateRepositoriesProperty == null) {
+                throw new FileNotFoundException("Could not find artifact " + mc.toArtifactFilename() 
+                        + " in Maven central, and no other alternate 'binaries.repositories' were found.");
+            }
+            String [] alternateRepositories = alternateRepositoriesProperty.trim().split("\\s+");
+            for (String alternateRepository : alternateRepositories) {
+                try {
+                    u = new URL(alternateRepository + cacheName);
+                    return downloadFromServer(u);
+                } catch (FileNotFoundException notInAlternateRepository) {
+                    // Ignored to keep on trying next alternate repository
+                }
+            }
+            throw new FileNotFoundException("Could not download artifact " + mc.toArtifactFilename() 
+                + " from Maven central nor other " + alternateRepositories.length + " alternate repositories.");
+        }
     }
 
     private void fillInFile(String expectedHash, String baseName, File manifest, Downloader download) throws BuildException {
@@ -274,6 +295,9 @@ private void doDownload(String cacheName, File destination, String expectedHash,
         if (conn instanceof HttpURLConnection) {
             code = ((HttpURLConnection) conn).getResponseCode();
         }
+        if (code == HttpURLConnection.HTTP_NOT_FOUND) {
+            throw new FileNotFoundException("Could not find artifact in this URL.");
+        }
         if (code != HttpURLConnection.HTTP_OK) {
             throw new IOException("Skipping download from " + url + " due to response code " + code);
         }
@@ -407,7 +431,7 @@ private MavenCoordinate(String groupId, String artifactId, String version, Strin
             this.extension = extension;
             this.classifier = classifier;
         }
-        
+
         public boolean hasClassifier() {
             return (! classifier.isEmpty());
         }
diff --git a/nbbuild/default-properties.xml b/nbbuild/default-properties.xml
index 0e4412c4c..a68bedba5 100644
--- a/nbbuild/default-properties.xml
+++ b/nbbuild/default-properties.xml
@@ -68,6 +68,8 @@
   
   <property name="binaries.cache" location="${user.home}/.hgexternalcache"/>
   <property name="binaries.server" value="http://hg.netbeans.org/binaries/"/>
+  <!-- A space separated, sorted list of alternate repositories used to download artifacts when not found in Maven central -->
+  <property name="binaries.repositories" value="https://repo.eclipse.org/service/local/repositories/acceleo-releases/content/" />
 
   <target name="-load-build-properties">
     <property file="${nb_all}/nbbuild/build.properties"/>
diff --git a/netbinox/external/binaries-list b/netbinox/external/binaries-list
index b59ac8ebb..f4827a475 100644
--- a/netbinox/external/binaries-list
+++ b/netbinox/external/binaries-list
@@ -14,4 +14,4 @@
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
-E5DDC5E827D3D62E7BE9F7E32927CA01F2839971 org.eclipse.osgi_3.9.1.v20140110-1610.jar
+4499D6104182D349F0EC59D6D166123AA5F09174 org.eclipse.core:org.eclipse.osgi:3.9.1.v20140110-1610
diff --git a/netbinox/nbproject/project.properties b/netbinox/nbproject/project.properties
index 2144ee42d..5c506527b 100644
--- a/netbinox/nbproject/project.properties
+++ b/netbinox/nbproject/project.properties
@@ -16,7 +16,7 @@
 # under the License.
 
 is.autoload=true
-release.external/org.eclipse.osgi_3.9.1.v20140110-1610.jar=modules/ext/org.eclipse.osgi_3.9.1.v20140110-1610.jar
+release.external/org.eclipse.osgi-3.9.1.v20140110-1610.jar=modules/ext/org.eclipse.osgi_3.9.1.v20140110-1610.jar
 javac.source=1.6
 javac.target=1.7
 javac.compilerargs=-Xlint -Xlint:-serial
diff --git a/netbinox/nbproject/project.xml b/netbinox/nbproject/project.xml
index 50bdc2404..beb06919c 100644
--- a/netbinox/nbproject/project.xml
+++ b/netbinox/nbproject/project.xml
@@ -123,7 +123,7 @@
             </public-packages>
             <class-path-extension>
                 <runtime-relative-path>ext/org.eclipse.osgi_3.9.1.v20140110-1610.jar</runtime-relative-path>
-                <binary-origin>external/org.eclipse.osgi_3.9.1.v20140110-1610.jar</binary-origin>
+                <binary-origin>external/org.eclipse.osgi-3.9.1.v20140110-1610.jar</binary-origin>
             </class-path-extension>
         </data>
     </configuration>


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services