Skip to content
This repository has been archived by the owner on May 13, 2023. It is now read-only.

Commit

Permalink
Offline builds and fix buildscript entrypoint
Browse files Browse the repository at this point in the history
I am not sure how the buildscript entrypoint worked at some point,
but then it didn't work anymore because it couldn't resolve the buildscript
class. Thus, we will compile that class if it was not found
  • Loading branch information
Geolykt committed Apr 14, 2022
1 parent e8fe913 commit 5d70e49
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 10 deletions.
2 changes: 1 addition & 1 deletion brachyura/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>io.github.coolcrabs</groupId>
<artifactId>brachyura</artifactId>
<version>0.76.0</version>
<version>0.76.1</version>

<properties>
<java.version>1.8</java.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class Plugins {
private Plugins() { }

static ArrayList<Plugin> plugins = new ArrayList<>();

static {
plugins.add(ProfilePlugin.INSTANCE); // TODO: real plugin loading
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,20 @@ public static void main(String[] args) throws Throwable {
try {
EntryGlobals.projectDir = Paths.get(args[0]);
EntryGlobals.buildscriptClasspath = Arrays.stream(args[1].split(File.pathSeparator)).map(Paths::get).collect(Collectors.toList());
Project buildscript = (Project) Class.forName("Buildscript").getDeclaredConstructor().newInstance();

Project buildscript;
try {
buildscript = (Project) Class.forName("Buildscript").getDeclaredConstructor().newInstance();
} catch (ClassNotFoundException cnfe) {
buildscript = new BuildscriptProject().createProject().get();
}
// "finalBuildscript" is just "buildscript" but local-class friendly
Project finalBuildscript = buildscript;
BuildscriptProject buildscriptProject = new BuildscriptProject() {
@Override
public Optional<Project> createProject() {
return Optional.of(buildscript);
}
public java.util.Optional<Project> createProject() {
return Optional.of(finalBuildscript);
};
};
buildscript.setIdeProject(buildscriptProject);
Tasks t = new Tasks();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,15 @@ public static void main(String[] args) throws Exception {
for (String lib : mavenLibs) {
boolean isJar = !lib.endsWith("-sources.jar");
String filename = lib.substring(lib.lastIndexOf('/') + 1);
HttpURLConnection connection = (HttpURLConnection) new URL(lib + ".sha1").openConnection();
connection.setRequestProperty("User-Agent", "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.4; en-US; rv:1.9.2.2) Gecko/20100316 Firefox/3.6.2"); // hydos moment
String hash;
try (InputStream is = connection.getInputStream()) {
hash = readFullyAsString(is);
if (!Boolean.getBoolean("de.geolykt.starloader.brachyura.build.offline")) {
HttpURLConnection connection = (HttpURLConnection) new URL(lib + ".sha1").openConnection();
connection.setRequestProperty("User-Agent", "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.4; en-US; rv:1.9.2.2) Gecko/20100316 Firefox/3.6.2"); // hydos moment
try (InputStream is = connection.getInputStream()) {
hash = readFullyAsString(is);
}
} else {
hash = "offline-build";
}
bootstrapConfigWriter.write(lib + "\t" + hash + "\t" + filename + "\t" + isJar + "\n");
}
Expand Down
12 changes: 12 additions & 0 deletions offline-build.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash
set -e
cd brachyura
mvn clean package verify -Dmaven.test.skip=true --offline
cd ..
cd bootstrap
mvn clean package verify -Dmaven.test.skip=true --offline
cd ..
cd build
mvn clean package verify -Dmaven.test.skip=true --offline
java -Dde.geolykt.starloader.brachyura.build.offline=true -jar ./target/brachyura-build-0.jar
cd ..

0 comments on commit 5d70e49

Please sign in to comment.