build the server with nix
This commit is contained in:
parent
cb905eec81
commit
c90059f532
4 changed files with 98 additions and 0 deletions
24
build.gradle
24
build.gradle
|
@ -9,3 +9,27 @@ plugins {
|
|||
task clean(type: Delete) {
|
||||
delete rootProject.buildDir
|
||||
}
|
||||
|
||||
task resolveDependencies {
|
||||
doLast {
|
||||
project.rootProject.allprojects.each { subProject ->
|
||||
subProject.buildscript.configurations.each { configuration ->
|
||||
resolveConfiguration(subProject, configuration, "buildscript config '${configuration.name}'")
|
||||
}
|
||||
subProject.configurations.each { configuration ->
|
||||
resolveConfiguration(subProject, configuration, "config '${configuration.name}'")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void resolveConfiguration(subProject, configuration, name) {
|
||||
// TODO: fix this
|
||||
if (subProject.name == "app") {
|
||||
return;
|
||||
}
|
||||
if (configuration.canBeResolved) {
|
||||
logger.info("Resolving project {} {}", subProject.name, name)
|
||||
configuration.resolve()
|
||||
}
|
||||
}
|
||||
|
|
37
flake.nix
37
flake.nix
|
@ -35,5 +35,42 @@
|
|||
# override the aapt2 that gradle uses with the nix-shipped version
|
||||
GRADLE_OPTS = "-Dorg.gradle.project.android.aapt2FromMavenOverride=${androidSdk}/libexec/android-sdk/build-tools/32.0.0/aapt2";
|
||||
};
|
||||
packages = rec {
|
||||
invtracker-deps = pkgs.stdenv.mkDerivation {
|
||||
pname = "invtracker-deps";
|
||||
version = self.lastModifiedDate;
|
||||
src = self;
|
||||
nativeBuildInputs = with pkgs; [ gradle openjdk_headless perl ];
|
||||
buildPhase = ''
|
||||
export GRADLE_USER_HOME=$(mktemp -d)
|
||||
# Fetch the maven deps
|
||||
gradle --no-daemon --info -Dorg.gradle.java.home=${pkgs.openjdk_headless} resolveDependencies
|
||||
'';
|
||||
installPhase = ''
|
||||
find $GRADLE_USER_HOME/caches/modules-2 -type f -regex '.*\.\(jar\|pom\)$' \
|
||||
| perl -pe 's#(.*/([^/]+)/([^/]+)/([^/]+)/[0-9a-f]{30,40}/([^/\s]+))$# ($x = $2) =~ tr|\.|/|; "install -Dm444 $1 \$out/maven/$x/$3/$4/$5" #e' \
|
||||
| sh
|
||||
'';
|
||||
outputHashAlgo = "sha256";
|
||||
outputHashMode = "recursive";
|
||||
outputHash = "sha256-OXNB19WPC5MyLEoDAtnVM9XykY7e0mKGRH5Aw8C/lMo=";
|
||||
};
|
||||
invtracker-server = pkgs.stdenv.mkDerivation {
|
||||
pname = "invtracker-server";
|
||||
version = self.lastModifiedDate;
|
||||
src = self;
|
||||
nativeBuildInputs = with pkgs; [ gradle openjdk_headless ];
|
||||
buildPhase = ''
|
||||
sed -i 's#gradlePluginPortal..#maven { url "${invtracker-deps}/maven" }#' settings.gradle
|
||||
sed -i 's#google..#maven { url "${invtracker-deps}/maven" }#' settings.gradle
|
||||
|
||||
export GRADLE_USER_HOME=$(mktemp -d)
|
||||
gradle --offline --no-daemon --info -Dorg.gradle.java.home=${pkgs.openjdk_headless} server:installDist
|
||||
'';
|
||||
installPhase = ''
|
||||
cp -rv server/build/install/server $out/
|
||||
'';
|
||||
};
|
||||
};
|
||||
});
|
||||
}
|
||||
|
|
1
result
Symbolic link
1
result
Symbolic link
|
@ -0,0 +1 @@
|
|||
/nix/store/llwxk8hih9hrw235472f14d2ds4m4qyh-invtracker-server-20220813100940
|
|
@ -25,18 +25,48 @@ import rs.chir.db.DBConnection;
|
|||
import rs.chir.invtracker.model.Cursor;
|
||||
import rs.chir.invtracker.model.GeoLocation;
|
||||
|
||||
/**
|
||||
* A table for storing locations for tracked items.
|
||||
*/
|
||||
public class LocationLogTable implements Map<Long, GeoLocation> {
|
||||
/**
|
||||
* The page size to use for API cursors
|
||||
*/
|
||||
private static final int PAGE_SIZE = 50;
|
||||
/**
|
||||
* The database connection to use for accessing the table.
|
||||
*/
|
||||
private final DBConnection dbConnection;
|
||||
/**
|
||||
* The user ID to use for accessing the table.
|
||||
*/
|
||||
private final long userId;
|
||||
/**
|
||||
* The item ID to use for accessing the table.
|
||||
*/
|
||||
private final long itemId;
|
||||
|
||||
/**
|
||||
* Creates a new table.
|
||||
*
|
||||
* @param dbConnection the database connection to use for accessing the table.
|
||||
* @param userId the user ID to use for accessing the table.
|
||||
* @param itemId the item ID to use for accessing the table.
|
||||
*/
|
||||
private LocationLogTable(DBConnection dbConnection, long userId, long itemId) {
|
||||
this.dbConnection = dbConnection;
|
||||
this.userId = userId;
|
||||
this.itemId = itemId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the table for the given user and item.
|
||||
*
|
||||
* @param dbConnection the database connection to use for accessing the table.
|
||||
* @param userId the user ID to use for accessing the table.
|
||||
* @param itemId the item ID to use for accessing the table.
|
||||
* @return the new table.
|
||||
*/
|
||||
@NonNull
|
||||
public static LocationLogTable getInstance(@NonNull DBConnection dbConnection, long userId, long itemId) {
|
||||
// TODO: add caching maybe
|
||||
|
@ -45,6 +75,12 @@ public class LocationLogTable implements Map<Long, GeoLocation> {
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a row from the database to a location.
|
||||
* @param resultSet the result set to convert.
|
||||
* @return the location.
|
||||
* @throws SQLException if an error occurs.
|
||||
*/
|
||||
@NonNull
|
||||
@Contract("_ -> new")
|
||||
private static GeoLocation fromResultSet(@NonNull ResultSet rs) throws SQLException {
|
||||
|
|
Loading…
Reference in a new issue