= Files

You can define a set of additional files that should be uploaded as part of the release. These files may also
be checksumed and signed before uploading.

include::partial$legend.adoc[]

[tabs]
====
YAML::
+
[source,yaml]
[subs="+macros"]
----
# icon:dot-circle[]
files:

  # Defines a list of artifacts.
  # Each entry must define a path: field.
  # The path may be relative to the project's basedir or absolute.
  # icon:dot-circle[] icon:file-alt[]
  artifacts:
    - path: path/to/some/file.txt
    - path: path/to/another/file.md

  # Defines a list of globs.
  # icon:dot-circle[]
  globs:
      # The directory to search.
      # If undefined, will use the project's basedir.
      # icon:dot-circle[] icon:file-alt[]
    - directory: some/directory\

      # The pattern to apply for inclusion.
      # If undefined, will use `*`.
      # icon:dot-circle[]
      include: '*.txt'

      # The pattern to apply for exclusion.
      # icon:dot-circle[]
      exclude: 'secret'

      # Recursive search.
      # Defaults to `false`.
      # icon:dot-circle[]
      recursive: true
----
TOML::
+
[source,toml]
[subs="+macros"]
----
# icon:dot-circle[]
[files]

  # Defines a list of artifacts.
  # Each entry must define a path: field.
  # The path may be relative to the project's basedir or absolute.
  # icon:dot-circle[] icon:file-alt[]
  artifact = [
    { path = "path/to/some/file.txt" },
    { path = "path/to/another/file.md" }
  ]

  # Defines a list of globs.
  # icon:dot-circle[]
  pass:[[[files.globs]]]
    # The directory to search.
    # If undefined, will use the project's basedir.
    # icon:dot-circle[] icon:file-alt[]
    directory = "some/directory"

    # The pattern to apply for inclusion.
    # If undefined, will use `*`.
    # icon:dot-circle[]
    include = "*.txt"

    # The pattern to apply for exclusion.
    # icon:dot-circle[]
    exclude = "secret"

    # Recursive search.
    # Defaults to `false`.
    # icon:dot-circle[]
    recursive = true
----
JSON::
+
[source,json]
[subs="+macros"]
----
{
  // icon:dot-circle[]
  "files": {

     // Defines a list of files.
     // Each entry must define a path: field.
     // The path may be relative to the project's basedir or absolute.
     // icon:dot-circle[] icon:file-alt[]
    "artifacts": [
      {
        "path": "path/to/some/file.txt"
      },
      {
        "path": "path/to/another/file.md"
      }
    ],

    // Defines a list of globs.
    // icon:dot-circle[]
    "globs": [
      {
        // The directory to search.
        // If undefined, will use the project's basedir.
        // icon:dot-circle[] icon:file-alt[]
        "directory": "some/directory",

        // The pattern to apply for inclusion.
        // If undefined, will use `*`.
        // icon:dot-circle[]
        "include": "*.txt",

        // The pattern to apply for exclusion.
        // icon:dot-circle[]
        "exclude": "secret",

        // Recursive search.
        // Defaults to `false`.
        // icon:dot-circle[]
        "recursive": true
      }
    ]
  }
}
----
Maven::
+
[source,xml]
[subs="+macros,verbatim"]
----
<jreleaser>
  <!--
    icon:dot-circle[]
  -->
  <files>

    <!--
      Defines a list of files.
      Each entry must define a path: field.
      The path may be relative to the project's basedir or absolute.
      icon:dot-circle[] icon:file-alt[]
    -->
    <artifacts>
      <artifact>
        <path>path/to/some/file.txt</path>
      <artifact>
      </artifact>
        <path>path/to/another/file.md</path>
      </artifact>
    </artifacts>

    <!--
      Defines a list of globs.
      icon:dot-circle[]
    -->
    <globs>
      <glob>
        <!--
          The directory to search.
          If undefined, will use the project's basedir.
          icon:dot-circle[] icon:file-alt[]
        -->
        <directory>some/directory</directory>

        <!--
          The pattern to apply for inclusion.
          If undefined, will use `*`.
          icon:dot-circle[]
        -->
        <include>*.txt</include>

        <!--
         The pattern to apply for exclusion.
         icon:dot-circle[]
        -->
        <exclude>secret</exclude>

        <!--
          Recursive search.
          Defaults to `false`.
          icon:dot-circle[]
        -->
        <recursive>true</recursive>
      </glob>
    </globs>
  </files>
</jreleaser>
----
Gradle::
+
[source,groovy]
[subs="+macros"]
----
jreleaser {
  // icon:dot-circle[]
  files {
    // Defines a file entry
    // The path may be relative to the project's basedir or absolute.
    // icon:dot-circle[] icon:file-alt[]
    artifact {
      path = 'path/to/some/file.txt'
    }
    artifact {
      path = 'path/to/another/file.md'
    }

    // Defines a glob entry
    // icon:dot-circle[]
    glob {
      // The directory to search.
      // If undefined, will use the project's basedir.
      // icon:dot-circle[] icon:file-alt[]
      directory = 'some/directory'

      // The pattern to apply for inclusion.
      // If undefined, will use `*`.
      // icon:dot-circle[]
      include = '*.txt'

      // The pattern to apply for exclusion.
      // icon:dot-circle[]
      exclude = 'secret'

      // Recursive search.
      // Defaults to `false`.
      // icon:dot-circle[]
      recursive = true
    }
  }
}
----
====

WARNING: One of `glob.directory`, `glob.include`, `glob.exclude` must be defined at the very least, otherwise the search
would encompass the whole project.

Use the `include` and `exclude` patterns to narrow the search, for example given the following structure:

[source]
----
src/files
├── secret
│   └── waldos-location.txt
└── todo.txt
----

We'd like to include all `*.txt` files without giving away Waldo's location; we can do this by using `include` and `exclude`
like so:

[tabs]
====
YAML::
+
[source,yaml]
[subs="+macros"]
----
files:
  globs:
    - directory: src/files
      include: '*.txt'
      exclude: 'secret'
      recursive: true
----
TOML::
+
[source,toml]
[subs="+macros"]
----
pass:[[[files.globs]]]
  directory = "src/files"
  include = "*.txt"
  exclude = "secret"
  recursive = true
----
JSON::
+
[source,json]
[subs="+macros"]
----
{
  "files": {
    "globs": [
      {
        "directory": "src/files",
        "include": "*.txt",
        "exclude": "secret",
        "recursive": true
      }
    ]
  }
}
----
Maven::
+
[source,xml]
[subs="+macros,verbatim"]
----
<jreleaser>
  <files>
    <globs>
      <glob>
        <directory>src/files</directory>
        <include>*.txt</include>
        <exclude>secret</exclude>
        <recursive>true</recursive>
      </glob>
    </globs>
  </files>
</jreleaser>
----
Gradle::
+
[source,groovy]
[subs="+macros"]
----
jreleaser {
  files {
    glob {
      directory = 'src/files'
      include = '*.txt'
      exclude = 'secret'
      recursive = true
    }
  }
}
----
====

