initial commit

This commit is contained in:
zuckerberg 2021-08-13 21:48:57 -04:00
commit adce470b5b
9 changed files with 1512 additions and 0 deletions

5
.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
target
.classpath
.project
.settings
.vscode/

92
flake.lock generated Normal file
View File

@ -0,0 +1,92 @@
{
"nodes": {
"mvn2nix": {
"inputs": {
"nixpkgs": "nixpkgs",
"utils": "utils"
},
"locked": {
"lastModified": 1625869373,
"narHash": "sha256-ppW69EucMtn995HOdx+Vs1XyRnsvtHzilHCtNC2ZTQQ=",
"owner": "fzakaria",
"repo": "mvn2nix",
"rev": "23b078b7fd0bedda9e7d8541877f255a54794100",
"type": "github"
},
"original": {
"owner": "fzakaria",
"repo": "mvn2nix",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1625176478,
"narHash": "sha256-s1RTYNKw7ySyqrZjns9Cq+Nnjpp75ePgL06pgcbIpoA=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "21b696caf392ad6fa513caf3327d0aa0430ffb72",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-21.05",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1628902850,
"narHash": "sha256-VDQVsZ4eIuiSd2A9iVEfJRIlt4Di2BDca3JMx23zWy0=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "e30d2b73ffdca48fe586ca0c4fd40a002de39021",
"type": "github"
},
"original": {
"id": "nixpkgs",
"type": "indirect"
}
},
"root": {
"inputs": {
"mvn2nix": "mvn2nix",
"nixpkgs": "nixpkgs_2",
"utils": "utils_2"
}
},
"utils": {
"locked": {
"lastModified": 1623875721,
"narHash": "sha256-A8BU7bjS5GirpAUv4QA+QnJ4CceLHkcXdRp4xITDB0s=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "f7e004a55b120c02ecb6219596820fcd32ca8772",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"utils_2": {
"locked": {
"lastModified": 1623875721,
"narHash": "sha256-A8BU7bjS5GirpAUv4QA+QnJ4CceLHkcXdRp4xITDB0s=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "f7e004a55b120c02ecb6219596820fcd32ca8772",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

20
flake.nix Normal file
View File

@ -0,0 +1,20 @@
{
inputs = {
mvn2nix.url = "github:fzakaria/mvn2nix";
utils.url = "github:numtide/flake-utils";
};
outputs = { nixpkgs, mvn2nix, utils, ... }:
let
pkgsForSystem = system: import nixpkgs {
overlays = [ mvn2nix.overlay (import ./nix/overlay.nix) ];
inherit system;
};
in utils.lib.eachSystem utils.lib.defaultSystems (system: rec {
legacyPackages = pkgsForSystem system;
packages = utils.lib.flattenTree {
inherit (legacyPackages) dbuild;
};
defaultPackage = legacyPackages.dbuild;
});
}

38
nix/dbuild.nix Normal file
View File

@ -0,0 +1,38 @@
{ lib, stdenv, buildMavenRepositoryFromLockFile
, makeWrapper, maven, jdk11_headless
, nix-gitignore
}:
let
mavenRepository = buildMavenRepositoryFromLockFile { file = ./mvn2nix-lock.json; };
in stdenv.mkDerivation rec {
pname = "dBuild";
version = "0.0.1";
name = "${pname}-${version}";
src = nix-gitignore.gitignoreSource [ "*.nix" ] ./..;
nativeBuildInputs = [ jdk11_headless maven makeWrapper ];
buildPhase = ''
echo "Building with maven repository ${mavenRepository}"
mvn package --offline -Dmaven.repo.local=${mavenRepository}
'';
installPhase = ''
# create the bin directory
mkdir -p $out/bin
# create a symbolic link for the lib directory
ln -s ${mavenRepository} $out/lib
# copy out the JAR
# Maven already setup the classpath to use m2 repository layout
# with the prefix of lib/
cp target/${name}.jar $out/
# create a wrapper that will automatically set the classpath
# this should be the paths from the dependency derivation
makeWrapper ${jdk11_headless}/bin/java $out/bin/${pname} \
--add-flags "-jar $out/${name}.jar"
'';
}

1249
nix/mvn2nix-lock.json Normal file

File diff suppressed because it is too large Load Diff

3
nix/overlay.nix Normal file
View File

@ -0,0 +1,3 @@
final: prev: {
dbuild = final.callPackage ./dbuild.nix { };
}

82
pom.xml Normal file
View File

@ -0,0 +1,82 @@
<?xml version="1.0" encoding="UTF-8"?>
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.zuckerberg.dbuild</groupId>
<artifactId>dbuild</artifactId>
<version>0.0.1</version>
<name>dbuild</name>
<!-- FIXME change it to the project's website -->
<url>https://git.neet.dev/zuckerberg/dbuild</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
<configuration>
<archive>
<manifest>
<mainClass>com.zuckerberg.dbuild.Main</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>

View File

@ -0,0 +1,9 @@
package com.zuckerberg.dbuild;
public class Main
{
public static void main(String[] args)
{
System.out.println("Hello World!");
}
}

View File

@ -0,0 +1,14 @@
package com.zuckerberg.dbuild;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
public class MainTest
{
@Test
public void shouldAnswerWithTrue()
{
assertTrue( true );
}
}