Skip to content

Commit

Permalink
Don't use local .m2 cache in build by default.
Browse files Browse the repository at this point in the history
Always download Maven binaries by default rather than relying on local .m2 cache (issues with Jenkins builds).
Expose binaries.repos property so source repositories of binaries can be configured, including local .m2 if desired.
  • Loading branch information
neilcsmith-net committed Jan 25, 2021
1 parent 9b5068b commit a0e6cd8
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
import java.io.OutputStream;
import java.math.BigInteger;
import java.net.HttpURLConnection;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLConnection;
import java.nio.file.Files;
Expand Down Expand Up @@ -177,20 +179,22 @@ public void execute() throws BuildException {

private byte[] mavenFile(MavenCoordinate mc) throws IOException {
String cacheName = mc.toMavenPath();
File local = new File(new File(new File(new File(System.getProperty("user.home")), ".m2"), "repository"), cacheName.replace('/', File.separatorChar));
List<String> urls = new ArrayList<>();
if (local.isFile()) {
urls.add(local.toURI().toString());
}
for (String prefix : repos.split(" ")) {
urls.add(prefix + cacheName);
}
for (String url : urls) {
try {
if (url.startsWith("file:")) {
File file = new File(new URI(url));
if (!file.exists()) {
continue;
}
}
URL u = new URL(url);
log("Trying: " + url, Project.MSG_VERBOSE);
return downloadFromServer(u);
} catch (IOException ex) {
} catch (IOException | URISyntaxException ex) {
//Try the next URL
}
}
Expand Down
1 change: 1 addition & 0 deletions nbbuild/binaries-default-properties.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@
<project name="binaries-default-properties" default="netbeans" basedir=".">
<property name="binaries.cache" location="${user.home}/.hgexternalcache"/>
<property name="binaries.server" value="https://netbeans.osuosl.org/binaries/"/>
<property name="binaries.repos" value="https://repo1.maven.org/maven2/"/>
</project>
14 changes: 7 additions & 7 deletions nbbuild/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
<taskdef name="downloadbinaries" classname="org.netbeans.nbbuild.extlibs.DownloadBinaries" classpath="${build.ant.classes.dir}"/>
<taskdef name="configureproxy" classname="org.netbeans.nbbuild.extlibs.ConfigureProxy" classpath="${build.ant.classes.dir}"/>
<property name="have-downloadbinaries-task" value="true" />
<downloadbinaries cache="${binaries.cache}" server="${binaries.server}">
<downloadbinaries cache="${binaries.cache}" server="${binaries.server}" repos="${binaries.repos}">
<manifest dir="${nb_all}">
<include name="nbbuild/external/binaries-list"/>
<include name="platform/libs.junit4/external/binaries-list"/>
Expand Down Expand Up @@ -198,7 +198,7 @@ metabuild.hash=${metabuild.hash}</echo>
<target name="download-all-extbins" unless="ext.binaries.downloaded" depends="bootstrap">
<echo>Downloading external binaries (*/external/ directories)...</echo>
<!-- optionnal reporttofile used to speed resolving artefacts resolution for maven artefacts -->
<downloadbinaries cache="${binaries.cache}" server="${binaries.server}" >
<downloadbinaries cache="${binaries.cache}" server="${binaries.server}" repos="${binaries.repos}" >
<manifest dir="${nb_all}">
<include name="**/external/binaries-list"/>
</manifest>
Expand Down Expand Up @@ -235,7 +235,7 @@ metabuild.hash=${metabuild.hash}</echo>
<map from="${nb_all}/" to=""/>
<globmapper from="*" to="*/external/binaries-list"/>
</pathconvert>
<downloadbinaries cache="${binaries.cache}" server="${binaries.server}">
<downloadbinaries cache="${binaries.cache}" server="${binaries.server}" repos="${binaries.repos}">
<manifest dir="${nb_all}" includes="${modules.binaries-list}"/>
</downloadbinaries>
</target>
Expand Down Expand Up @@ -468,7 +468,7 @@ metabuild.hash=${metabuild.hash}</echo>
</target>

<target name="-download-nb-windows-launchers" depends="init,-check-nb-cluster" if="has.nb.cluster" unless="do.build.windows.launchers">
<downloadbinaries cache="${binaries.cache}" server="${binaries.server}">
<downloadbinaries cache="${binaries.cache}" server="${binaries.server}" repos="${binaries.repos}">
<manifest dir="${nb_all}" includes="nb/ide.launcher/external/binaries-list"/>
</downloadbinaries>

Expand Down Expand Up @@ -1310,7 +1310,7 @@ It is possible to use -Ddebug.port=3234 -Ddebug.pause=y to start the system in d
</fileset>
</subant>
<taskdef name="downloadbinaries" classname="org.netbeans.nbbuild.extlibs.DownloadBinaries" classpath="${nbantext.jar}"/>
<downloadbinaries cache="${binaries.cache}" server="${binaries.server}" clean="true">
<downloadbinaries cache="${binaries.cache}" server="${binaries.server}" repos="${binaries.repos}" clean="true">
<manifest dir="${nb_all}">
<include name="*/external/binaries-list"/>
<include name="contrib/*/external/binaries-list"/>
Expand Down Expand Up @@ -1689,7 +1689,7 @@ It is possible to use -Ddebug.port=3234 -Ddebug.pause=y to start the system in d
<pathconvert property="source.dirs" pathsep="," refid="source.dirset">
<regexpmapper from="${nb_all}/(.*)$" to="\1/**/*" handledirsep="yes"/>
</pathconvert>
<downloadbinaries cache="${binaries.cache}" server="${binaries.server}"> <!--XXX-->
<downloadbinaries cache="${binaries.cache}" server="${binaries.server}" repos="${binaries.repos}"> <!--XXX-->
<manifest dir="${nb_all}">
<include name="libs.antlr3.devel/external/binaries-list"/>
</manifest>
Expand Down Expand Up @@ -2172,7 +2172,7 @@ It is possible to use -Ddebug.port=3234 -Ddebug.pause=y to start the system in d
<taskdef name="exclusionsfromlicenseinfo" classname="org.netbeans.nbbuild.extlibs.ExclusionsFromLicenseInfo" classpath="${nbantext.jar}"/>
<taskdef name="reportFromLicenseinfo" classname="org.netbeans.nbbuild.extlibs.ReportFromLicenseinfo" classpath="${nbantext.jar}"/>

<downloadbinaries cache="${binaries.cache}" server="${binaries.server}">
<downloadbinaries cache="${binaries.cache}" server="${binaries.server}" repos="${binaries.repos}">
<manifest dir="${nb_all}">
<include name="nbbuild/external/binaries-list"/>
</manifest>
Expand Down

0 comments on commit a0e6cd8

Please sign in to comment.