<commit_before># Adaptation of the MIT-licensed work on `sbt2nix` done by <NAME>

{ fetchurl, stdenv }:
let
  defaultRepos = [
    http://central.maven.org/maven2
    http://oss.sonatype.org/content/repositories/releases
    http://oss.sonatype.org/content/repositories/public
    http://repo.typesafe.com/typesafe/releases
  ];
in

args@
{ # Example: "org.apache.httpcomponents"
  groupId
, # Example: "httpclient"
  artifactId
, # Example: "4.3.6"
  version
, # List of maven repositories from where to fetch the artifact.
  # Example: [ http://oss.sonatype.org/content/repositories/public ].
  repos ? defaultRepos
  # The `url` and `urls` parameters, if specified should point to the JAR
  # file and will take precedence over the `repos` parameter. Only one of `url`
  # and `urls` can be specified, not both.
, url ? ""
, urls ? []
, # The rest of the arguments are just forwarded to `fetchurl`.
  ...
}:

# only one of url and urls can be specified at a time.
assert (url == "") || (urls == []);
# if repos is empty, then url or urls must be specified.
assert (repos != []) || (url != "") || (urls != []);


let
  name_ =
    with stdenv.lib; concatStrings [
      (replaceChars ["."] ["_"] groupId) "_"
      (replaceChars ["."] ["_"] artifactId) "-"
      version
    ];
  mkJarUrl = repoUrl:
    with stdenv.lib; concatStringsSep "/" [
      (removeSuffix "/" repoUrl)
      (replaceChars ["."] ["/"] groupId)
      artifactId
      version
      "${artifactId}-${version}.jar"
    ];
  urls_ =
    if url != "" then [url]
    else if urls != [] then urls
    else map mkJarUrl repos;
  jar =
    fetchurl (
      builtins.removeAttrs args ["groupId" "artifactId" "version" "repos" "url" ]
        // { urls = urls_; name = "${name_}.jar"; }
    );
in
  stdenv.mkDerivation {
    name = name_;
    phases = "installPhase fixupPhase";
    # By moving the jar to $out/share/java we make it discoverable by java
    # packages packages that mention this derivation in their buildInputs.
    installPhase = ''
      mkdir -p $out/share/java
      ln -s ${jar} $out/share/java
    '';
    # We also add a `jar` attribute that can be used to easily obtain the path
    # to the downloaded jar file.
    passthru.jar = jar;
  }<commit_msg>fetchMavenArtifact: prevent leaking nix hash to jar name<commit_after># Adaptation of the MIT-licensed work on `sbt2nix` done by <NAME>

{ fetchurl, stdenv }:
let
  defaultRepos = [
    http://central.maven.org/maven2
    http://oss.sonatype.org/content/repositories/releases
    http://oss.sonatype.org/content/repositories/public
    http://repo.typesafe.com/typesafe/releases
  ];
in

args@
{ # Example: "org.apache.httpcomponents"
  groupId
, # Example: "httpclient"
  artifactId
, # Example: "4.3.6"
  version
, # List of maven repositories from where to fetch the artifact.
  # Example: [ http://oss.sonatype.org/content/repositories/public ].
  repos ? defaultRepos
  # The `url` and `urls` parameters, if specified should point to the JAR
  # file and will take precedence over the `repos` parameter. Only one of `url`
  # and `urls` can be specified, not both.
, url ? ""
, urls ? []
, # The rest of the arguments are just forwarded to `fetchurl`.
  ...
}:

# only one of url and urls can be specified at a time.
assert (url == "") || (urls == []);
# if repos is empty, then url or urls must be specified.
assert (repos != []) || (url != "") || (urls != []);


let
  name_ =
    with stdenv.lib; concatStrings [
      (replaceChars ["."] ["_"] groupId) "_"
      (replaceChars ["."] ["_"] artifactId) "-"
      version
    ];
  mkJarUrl = repoUrl:
    with stdenv.lib; concatStringsSep "/" [
      (removeSuffix "/" repoUrl)
      (replaceChars ["."] ["/"] groupId)
      artifactId
      version
      "${artifactId}-${version}.jar"
    ];
  urls_ =
    if url != "" then [url]
    else if urls != [] then urls
    else map mkJarUrl repos;
  jar =
    fetchurl (
      builtins.removeAttrs args ["groupId" "artifactId" "version" "repos" "url" ]
        // { urls = urls_; name = "${name_}.jar"; }
    );
in
  stdenv.mkDerivation {
    name = name_;
    phases = "installPhase fixupPhase";
    # By moving the jar to $out/share/java we make it discoverable by java
    # packages packages that mention this derivation in their buildInputs.
    installPhase = ''
      mkdir -p $out/share/java
      ln -s ${jar} $out/share/java/${artifactId}-${version}.jar
    '';
    # We also add a `jar` attribute that can be used to easily obtain the path
    # to the downloaded jar file.
    passthru.jar = jar;
  }
{'fraction_non_alphanumeric': 0.14003511852502196, 'fraction_numerical': 0.0021949078138718174, 'mean_word_length': 2.8520710059171597, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5824621', 'n_tokens_mistral': 1552, 'n_tokens_neox': 1480, 'n_words': 457}