Skip to content

Commit 8a229af

Browse files
authored
Merge pull request #157 from VariantSync/develop
Release 2.3.0
2 parents 324a643 + 1661d8c commit 8a229af

200 files changed

Lines changed: 2723 additions & 3522 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.editorconfig

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
root = true
2+
3+
# We let Git handle end_of_line such that this setting is effectively platform
4+
# dependent but still normalized in the Git store. See .gitattributes
5+
6+
[*]
7+
charset = utf-8
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
indent_style = space
11+
indent_size = 4
12+
13+
[*.nix]
14+
indent_size = 2

.github/workflows/maven.yml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,14 @@ jobs:
1616
runs-on: ubuntu-latest
1717

1818
steps:
19-
- uses: actions/checkout@v3
20-
- name: Install Nix with cached packages
21-
uses: rikhuijzer/[email protected]
22-
with:
23-
key: nix-${{ hashFiles('.github/workflows/maven.yml', 'default.nix', 'nix/**', 'pom.xml', 'local-maven-repo') }}
24-
nix_file: nix/github-workflow-dependencies.nix
19+
- uses: actions/checkout@v4
20+
- uses: cachix/install-nix-action@v31
21+
# The dependencies could be cached if necessary. See PR #156 and da11a13c1451f5a52672fe494ac6e20116346865 for additional information.
2522
- name: Build
2623
run: nix-build
2724
- name: Upload Javadoc artifact
2825
if: ${{ github.event_name == 'push' && github.event.ref == 'refs/heads/main' }}
29-
uses: actions/upload-pages-artifact@v1
26+
uses: actions/upload-pages-artifact@v3
3027
with:
3128
path: result/share/github-pages/DiffDetective
3229

@@ -50,7 +47,7 @@ jobs:
5047
steps:
5148
- name: Publish Javadoc to Github Pages
5249
id: deployment
53-
uses: actions/deploy-pages@v1
50+
uses: actions/deploy-pages@v4
5451

5552
# Kill in progress deployments because only the newest version is relevant
5653
# and concurrent deployments cause CI failures.

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ To add DiffDetective as a dependency to your own project, add the following snip
4949
<dependency>
5050
<groupId>org.variantsync</groupId>
5151
<artifactId>DiffDetective</artifactId>
52-
<version>2.2.0</version>
52+
<version>2.3.0</version>
5353
</dependency>
5454
```
5555

56-
If you prefer to just use a jar file, you can find a jar file with all dependencies at `DiffDetective/target/diffdetective-2.2.0-jar-with-dependencies.jar` (again, the version number might be different).
56+
If you prefer to just use a jar file, you can find a jar file with all dependencies at `DiffDetective/target/diffdetective-2.3.0-jar-with-dependencies.jar` (again, the version number might be different).
5757
You can (re-)produce this jar file by either running `mvn package` or `mvn install` within you local clone of DiffDetective.
5858

5959
> Disclaimer: Setup tested with maven version 3.6.3.
@@ -68,7 +68,7 @@ nix build # Flake version
6868
```
6969
In case you are using Nix Flakes, you can skip cloning the repository as usual: `nix build github:VariantSync/DiffDetective#.`
7070

71-
Afterward, the [result](result) symlink points to the [Javadoc](result/share/github-pages/DiffDetective/docs/javadoc/index.html), the [DiffDetective jar](result/share/java/DiffDetective/DiffDetective.jar) and a simple [script](result/bin/DiffDetective) for executing a DiffDetective main class provided as argument (e.g., evaluations used in previous research, see below under 'Publications').
71+
Afterward, the [result](result) symlink points to the [Javadoc](result/share/github-pages/DiffDetective/docs/javadoc/index.html), a [DiffDetective jar for use as a library](result/share/java/DiffDetective.jar), a [self contained DiffDetective jar with all dependencies included](result/share/java/DiffDetective/DiffDetective-jar-with-dependencies.jar) and a simple [script](result/bin/DiffDetective) for executing a DiffDetective main class provided as argument (e.g., evaluations used in previous research, see below under 'Publications').
7272

7373

7474
## How to Get Started

default.nix

Lines changed: 90 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,65 +3,111 @@
33
system ? builtins.currentSystem,
44
pkgs ?
55
import sources.nixpkgs {
6-
overlays = [];
6+
overlays = [
7+
(final: previous: {
8+
defaultGemConfig = previous.defaultGemConfig // {
9+
jekyll-github-metadata = attrs: {
10+
dontBuild = false;
11+
patches = [
12+
(final.fetchpatch {
13+
url = "https://github.com/jekyll/github-metadata/commit/17cc5af5e1fd95d98d43676610cc8a47969350ab.patch";
14+
hash = "sha256-dUqvnYsjfG5xQIYS48B3xz0GLVYo2BrDAnYUafmDFKw=";
15+
relative = "lib";
16+
stripLen = 1;
17+
extraPrefix = "lib/jekyll-github-metadata/";
18+
})
19+
];
20+
};
21+
};
22+
})
23+
];
724
config = {};
825
inherit system;
926
},
1027
doCheck ? true,
1128
buildGitHubPages ? true,
29+
dependenciesHash ? "sha256-OdagSk6jYCkkw/kPoOJlma9yEK7hMBcNkuxE6qt0ra8=",
1230
}:
1331
pkgs.stdenvNoCC.mkDerivation rec {
1432
pname = "DiffDetective";
1533
# The single source of truth for the version number is stored in `pom.xml`.
1634
# Hence, this XML file needs to be parsed to extract the current version.
1735
version = pkgs.lib.removeSuffix "\n" (pkgs.lib.readFile
18-
(pkgs.runCommandLocal "DiffDetective-version" {}
19-
"${pkgs.xq-xml}/bin/xq -x '/project/version' ${./pom.xml} > $out"));
36+
(pkgs.runCommandLocal "DiffDetective-version" {
37+
nativeBuildInputs = [pkgs.xq-xml];
38+
} "xq -x '/project/version' ${./pom.xml} > $out"));
2039
src = with pkgs.lib.fileset;
2140
toSource {
2241
root = ./.;
2342
fileset = gitTracked ./.;
2443
};
2544

26-
nativeBuildInputs = with pkgs; [
27-
maven
28-
makeWrapper
29-
graphviz
30-
] ++ pkgs.lib.optional buildGitHubPages (ruby.withPackages (pkgs: with pkgs; [
31-
github-pages
32-
jekyll-theme-cayman
45+
nativeBuildInputs = [
46+
pkgs.maven
47+
pkgs.makeWrapper
48+
] ++ pkgs.lib.optional buildGitHubPages (pkgs.ruby.withPackages (rubyPkgs: [
49+
rubyPkgs.github-pages
50+
rubyPkgs.jekyll-theme-cayman
3351
]));
3452

53+
nativeCheckInputs = [
54+
pkgs.graphviz
55+
];
56+
57+
# Maven needs to download necessary dependencies which is impure because it
58+
# requires network access. Hence, we download all dependencies as a
59+
# fixed-output derivation. This also serves as a nice cache.
60+
#
61+
# We use the hash of the input files to invalidate the maven cache whenever
62+
# the input files change. This is purely for easing maintenance. In case a
63+
# maintainer forgets (or simply doesn't know) to change the output hash to
64+
# force a rebuild (and obtain the new, correct hash) this usually (without
65+
# this naming hack) result in use of a stall cash, essentially behaving like
66+
# an unreproducable derivation where a second build results in a different
67+
# output. By changing the name of the fixed output derivation whenever
68+
# `mavenRepoSrc` changes, we prevent this stall cache as the resulting store
69+
# path will never exist (except when the cache is valid).
70+
mavenRepoSrc = pkgs.lib.sourceByRegex ./. ["^pom.xml$" "^local-maven-repo(/.*)?$"];
71+
mavenRepoSrcName = with pkgs.lib; last (splitString "/" mavenRepoSrc.outPath);
3572
mavenRepo = pkgs.stdenv.mkDerivation {
36-
pname = "${pname}-mavenRepo";
73+
pname = "${pname}-mavenRepo-${mavenRepoSrcName}";
3774
inherit version;
38-
src = pkgs.lib.sourceByRegex ./. ["^pom.xml$" "^local-maven-repo(/.*)?$"];
75+
src = mavenRepoSrc;
3976

40-
nativeBuildInputs = with pkgs; [maven];
77+
nativeBuildInputs = [pkgs.maven];
4178

4279
buildPhase = ''
80+
runHook preBuild
81+
4382
mvn org.apache.maven.plugins:maven-dependency-plugin:3.6.0:go-offline -Dmaven.repo.local="$out"
83+
84+
runHook postBuild
4485
'';
4586

4687
# keep only *.{pom,jar,sha1,nbm} and delete all ephemeral files with lastModified timestamps inside
4788
installPhase = ''
89+
runHook preInstall
90+
4891
find "$out" -type f \
49-
\( -name \*.lastUpdated -or \
50-
-name resolver-status.properties -or \
51-
-name _remote.repositories \) \
92+
\( -not \( -name "*.pom" -o -name "*.jar" -o -name "*.sha1" -o -name "*.nbm" \) \
93+
-o -name "maven-metadata*" \) \
5294
-delete
95+
96+
runHook postInstall
5397
'';
5498

5599
dontFixup = true;
56100
dontConfigure = true;
57101
outputHashAlgo = "sha256";
58102
outputHashMode = "recursive";
59-
outputHash = "sha256-TYZP4XhM3ExLNC3H/QLch6LMVQxbR1LECwubMZn+RXY=";
103+
outputHash = dependenciesHash;
60104
};
61105

62-
jre-minimal = pkgs.callPackage (import "${sources.nixpkgs}/pkgs/development/compilers/openjdk/jre.nix") {
63-
modules = ["java.base" "java.desktop"];
64-
};
106+
# - `out` contains jars, an executable wrapper and optionally documentation
107+
# (see `buildGitHubPages`)
108+
# - `maven` contains a local maven repository with DiffDetective and all its
109+
# build-time and run-time dependencies.
110+
outputs = ["out" "maven"];
65111

66112
buildPhase = ''
67113
runHook preBuild
@@ -76,7 +122,8 @@ pkgs.stdenvNoCC.mkDerivation rec {
76122
if buildGitHubPages
77123
then ''
78124
mvn javadoc:javadoc
79-
JEKYLL_ENV=production PAGES_REPO_NWO=VariantSync/DiffDetective JEKYLL_BUILD_REVISION= github-pages build
125+
mv target/reports/apidocs docs/javadoc
126+
JEKYLL_ENV=production PAGES_REPO_NWO=VariantSync/DiffDetective JEKYLL_BUILD_REVISION= PAGES_DISABLE_NETWORK=1 github-pages build
80127
rm -rf _site/target
81128
''
82129
else ""
@@ -88,30 +135,46 @@ pkgs.stdenvNoCC.mkDerivation rec {
88135

89136
inherit doCheck;
90137
checkPhase = ''
91-
runHook postTest
138+
runHook preTest
92139
93140
mvn --offline -Dmaven.repo.local="$mavenRepo" test
94141
95142
runHook postTest
96143
'';
97144

98145
installPhase = ''
99-
runHook postInstall
146+
runHook preInstall
100147
101-
local jar="$out/share/java/DiffDetective/DiffDetective.jar"
102-
install -Dm644 "target/diffdetective-${version}-jar-with-dependencies.jar" "$jar"
103-
makeWrapper "${jre-minimal}/bin/java" "$out/bin/DiffDetective" --add-flags "-cp \"$jar\"" \
104-
--prefix PATH : "${pkgs.graphviz}/bin"
148+
# install jars in "$out"
149+
install -Dm644 "target/diffdetective-$version.jar" "$out/share/java/DiffDetective.jar"
150+
local jar="$out/share/java/DiffDetective/DiffDetective-jar-with-dependencies.jar"
151+
install -Dm644 "target/diffdetective-$version-jar-with-dependencies.jar" "$jar"
152+
makeWrapper \
153+
"${pkgs.jdk}/bin/java" "$out/bin/DiffDetective" \
154+
--add-flags "-cp \"$jar\"" \
155+
--prefix PATH : "${pkgs.lib.makeBinPath [pkgs.graphviz]}"
105156
106157
${
107158
if buildGitHubPages
108159
then ''
160+
# install documentation in "$out"
109161
mkdir "$out/share/github-pages"
110162
cp -r _site "$out/share/github-pages/DiffDetective"
111163
''
112164
else ""
113165
}
114166
167+
# install DiffDetective in "$maven" by creating a copy of "$mavenRepo" as base
168+
cp -r "$mavenRepo" "$maven"
169+
chmod u+w -R "$maven"
170+
mvn --offline -Dmaven.repo.local="$maven" -Dmaven.test.skip=true install
171+
172+
# keep only *.{pom,jar,sha1,nbm} and delete all ephemeral files with lastModified timestamps inside
173+
find "$maven" -type f \
174+
\( -not \( -name "*.pom" -o -name "*.jar" -o -name "*.sha1" -o -name "*.nbm" \) \
175+
-o -name "maven-metadata*" \) \
176+
-delete
177+
115178
runHook postInstall
116179
'';
117180

docker/entrypoint.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#!/bin/sh
22
if [ "$(id -u)" = "0" ]; then
3-
# running on a developer laptop as root
4-
fix-perms -r -u user -g user /home/user
5-
exec gosu user "$@"
3+
# running on a developer laptop as root
4+
fix-perms -r -u user -g user /home/user
5+
exec gosu user "$@"
66
else
7-
# running in production as a user
8-
exec "$@"
9-
fi
7+
# running in production as a user
8+
exec "$@"
9+
fi

docker/fix-perms.sh

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# update the uid
22
if [ -n "$opt_u" ]; then
3-
OLD_UID=$(getent passwd "${opt_u}" | cut -f3 -d:)
4-
NEW_UID=$(stat -c "%u" "$1")
5-
if [ "$OLD_UID" != "$NEW_UID" ]; then
6-
echo "Changing UID of $opt_u from $OLD_UID to $NEW_UID"
7-
usermod -u "$NEW_UID" -o "$opt_u"
8-
if [ -n "$opt_r" ]; then
9-
find / -xdev -user "$OLD_UID" -exec chown -h "$opt_u" {} \;
3+
OLD_UID=$(getent passwd "${opt_u}" | cut -f3 -d:)
4+
NEW_UID=$(stat -c "%u" "$1")
5+
if [ "$OLD_UID" != "$NEW_UID" ]; then
6+
echo "Changing UID of $opt_u from $OLD_UID to $NEW_UID"
7+
usermod -u "$NEW_UID" -o "$opt_u"
8+
if [ -n "$opt_r" ]; then
9+
find / -xdev -user "$OLD_UID" -exec chown -h "$opt_u" {} \;
10+
fi
1011
fi
11-
fi
12-
fi
12+
fi

0 commit comments

Comments
 (0)