We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Shading throws `NoSuchFileException` given a `deploy_jar` in a subdirectory 
**Describe the bug**
Given a `deploy_jar` target in a subdirectory shading process throws an exception `NoSuchFileException`

**Pants version**
2.18.0

**OS**
Ubuntu 22.04

**Additional info**
`helloworld/HelloWorld.java`:
```java
package helloworld;

public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, World!");
    }
}
```
`helloworld/BUILD`:
```python
java_sources(name="src")
```
`subdir/BUILD`:
```python
deploy_jar(
    name="fat",
    main="helloworld.HelloWorld",
    dependencies=["//helloworld:src"],
    shading_rules=[
        shading_keep(pattern="helloworld.**"),
    ],
)
```
It's important to put deploy_jar into a subdirectory. It works without errors if you put it into root BUILD file.
Steps to reproduce:
- pants generate-lockfiles
- pants subdir:fat

I get this:
```
ProcessExecutionFailure: Process 'Shading JAR subdir/fat.jar' failed with exit code 899.
...
java.nio.file.NoSuchFileException: subdir/fat.jar
...
```

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `src/python/pants/jvm/package/deploy_jar.py`
Content:
```
1 # Copyright 2021 Pants project contributors (see CONTRIBUTORS.md).
2 # Licensed under the Apache License, Version 2.0 (see LICENSE).
3 
4 import logging
5 from dataclasses import dataclass
6 from pathlib import PurePath
7 
8 from pants.core.goals.package import (
9     BuiltPackage,
10     BuiltPackageArtifact,
11     OutputPathField,
12     PackageFieldSet,
13 )
14 from pants.core.goals.run import RunFieldSet, RunInSandboxBehavior
15 from pants.engine.addresses import Addresses
16 from pants.engine.fs import EMPTY_DIGEST, AddPrefix, Digest, MergeDigests
17 from pants.engine.rules import Get, collect_rules, rule
18 from pants.engine.target import Dependencies
19 from pants.engine.unions import UnionRule
20 from pants.jvm import classpath
21 from pants.jvm.classpath import Classpath
22 from pants.jvm.compile import (
23     ClasspathDependenciesRequest,
24     ClasspathEntry,
25     ClasspathEntryRequest,
26     CompileResult,
27     FallibleClasspathEntries,
28     FallibleClasspathEntry,
29 )
30 from pants.jvm.jar_tool.jar_tool import JarToolRequest
31 from pants.jvm.jar_tool.jar_tool import rules as jar_tool_rules
32 from pants.jvm.shading.rules import ShadedJar, ShadeJarRequest
33 from pants.jvm.shading.rules import rules as shaded_jar_rules
34 from pants.jvm.strip_jar.strip_jar import StripJarRequest
35 from pants.jvm.subsystems import JvmSubsystem
36 from pants.jvm.target_types import (
37     DeployJarDuplicatePolicyField,
38     DeployJarExcludeFilesField,
39     DeployJarShadingRulesField,
40     JvmDependenciesField,
41     JvmJdkField,
42     JvmMainClassNameField,
43 )
44 
45 logger = logging.getLogger(__name__)
46 
47 
48 @dataclass(frozen=True)
49 class DeployJarFieldSet(PackageFieldSet, RunFieldSet):
50     required_fields = (
51         JvmMainClassNameField,
52         JvmJdkField,
53         Dependencies,
54         OutputPathField,
55     )
56     run_in_sandbox_behavior = RunInSandboxBehavior.RUN_REQUEST_HERMETIC
57 
58     main_class: JvmMainClassNameField
59     output_path: OutputPathField
60     dependencies: JvmDependenciesField
61     jdk_version: JvmJdkField
62     duplicate_policy: DeployJarDuplicatePolicyField
63     shading_rules: DeployJarShadingRulesField
64     exclude_files: DeployJarExcludeFilesField
65 
66 
67 class DeployJarClasspathEntryRequest(ClasspathEntryRequest):
68     field_sets = (DeployJarFieldSet,)
69     # A `deploy_jar` can have a Classpath requested for it, but should not be used as a dependency.
70     root_only = True
71 
72 
73 @rule
74 async def deploy_jar_classpath(
75     request: DeployJarClasspathEntryRequest,
76 ) -> FallibleClasspathEntry:
77     if len(request.component.members) > 1:
78         # If multiple DeployJar targets were coarsened into a single instance, it's because they
79         # formed a cycle among themselves... but at a high level, they shouldn't have dependencies
80         # on one another anyway.
81         raise Exception(
82             "`deploy_jar` targets should not depend on one another:\n"
83             f"{request.component.bullet_list()}"
84         )
85     fallible_entries = await Get(FallibleClasspathEntries, ClasspathDependenciesRequest(request))
86     classpath_entries = fallible_entries.if_all_succeeded()
87     if classpath_entries is None:
88         return FallibleClasspathEntry(
89             description=str(request.component),
90             result=CompileResult.DEPENDENCY_FAILED,
91             output=None,
92             exit_code=1,
93         )
94     return FallibleClasspathEntry(
95         description=str(request.component),
96         result=CompileResult.SUCCEEDED,
97         output=ClasspathEntry(EMPTY_DIGEST, dependencies=classpath_entries),
98         exit_code=0,
99     )
100 
101 
102 @rule
103 async def package_deploy_jar(
104     jvm: JvmSubsystem,
105     field_set: DeployJarFieldSet,
106 ) -> BuiltPackage:
107     """
108     Constructs a deploy ("fat") JAR file by
109     1. Resolving/compiling a Classpath for the `root_address` target,
110     2. Creating a deploy jar with a valid ZIP index and deduplicated entries
111     3. (optionally) Stripping the jar of all metadata that may cause it to be non-reproducible (https://reproducible-builds.org)
112     4. (optionally) Apply shading rules to the bytecode inside the jar file
113     """
114 
115     if field_set.main_class.value is None:
116         raise Exception("Needs a `main` argument")
117 
118     #
119     # 1. Produce thin JARs containing the transitive classpath
120     #
121 
122     classpath = await Get(Classpath, Addresses([field_set.address]))
123     classpath_digest = await Get(Digest, MergeDigests(classpath.digests()))
124 
125     #
126     # 2. Use Pants' JAR tool to build a runnable fat JAR
127     #
128 
129     output_filename = PurePath(field_set.output_path.value_or_default(file_ending="jar"))
130     jar_digest = await Get(
131         Digest,
132         JarToolRequest(
133             jar_name=output_filename.name,
134             digest=classpath_digest,
135             main_class=field_set.main_class.value,
136             jars=classpath.args(),
137             policies=[
138                 (rule.pattern, rule.action)
139                 for rule in field_set.duplicate_policy.value_or_default()
140             ],
141             skip=field_set.exclude_files.value,
142             compress=True,
143         ),
144     )
145 
146     #
147     # 3. Strip the JAR from  all non-reproducible metadata if requested so
148     #
149     if jvm.reproducible_jars:
150         jar_digest = await Get(
151             Digest,
152             StripJarRequest(
153                 digest=jar_digest,
154                 filenames=(output_filename.name,),
155             ),
156         )
157 
158     #
159     # 4. Apply shading rules
160     #
161     if field_set.shading_rules.value:
162         shaded_jar = await Get(
163             ShadedJar,
164             ShadeJarRequest(
165                 path=output_filename,
166                 digest=jar_digest,
167                 rules=field_set.shading_rules.value,
168                 skip_manifest=False,
169             ),
170         )
171         jar_digest = shaded_jar.digest
172 
173     prefixed_output_digest = await Get(Digest, AddPrefix(jar_digest, str(output_filename.parent)))
174     artifact = BuiltPackageArtifact(relpath=str(output_filename))
175     return BuiltPackage(digest=prefixed_output_digest, artifacts=(artifact,))
176 
177 
178 def rules():
179     return [
180         *collect_rules(),
181         *classpath.rules(),
182         *jar_tool_rules(),
183         *shaded_jar_rules(),
184         UnionRule(PackageFieldSet, DeployJarFieldSet),
185         UnionRule(ClasspathEntryRequest, DeployJarClasspathEntryRequest),
186     ]
187
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/src/python/pants/jvm/package/deploy_jar.py b/src/python/pants/jvm/package/deploy_jar.py
--- a/src/python/pants/jvm/package/deploy_jar.py
+++ b/src/python/pants/jvm/package/deploy_jar.py
@@ -155,6 +155,8 @@
             ),
         )
 
+    jar_digest = await Get(Digest, AddPrefix(jar_digest, str(output_filename.parent)))
+
     #
     # 4. Apply shading rules
     #
@@ -170,9 +172,8 @@
         )
         jar_digest = shaded_jar.digest
 
-    prefixed_output_digest = await Get(Digest, AddPrefix(jar_digest, str(output_filename.parent)))
     artifact = BuiltPackageArtifact(relpath=str(output_filename))
-    return BuiltPackage(digest=prefixed_output_digest, artifacts=(artifact,))
+    return BuiltPackage(digest=jar_digest, artifacts=(artifact,))
 
 
 def rules():

{"golden_diff": "diff --git a/src/python/pants/jvm/package/deploy_jar.py b/src/python/pants/jvm/package/deploy_jar.py\n--- a/src/python/pants/jvm/package/deploy_jar.py\n+++ b/src/python/pants/jvm/package/deploy_jar.py\n@@ -155,6 +155,8 @@\n             ),\n         )\n \n+    jar_digest = await Get(Digest, AddPrefix(jar_digest, str(output_filename.parent)))\n+\n     #\n     # 4. Apply shading rules\n     #\n@@ -170,9 +172,8 @@\n         )\n         jar_digest = shaded_jar.digest\n \n-    prefixed_output_digest = await Get(Digest, AddPrefix(jar_digest, str(output_filename.parent)))\n     artifact = BuiltPackageArtifact(relpath=str(output_filename))\n-    return BuiltPackage(digest=prefixed_output_digest, artifacts=(artifact,))\n+    return BuiltPackage(digest=jar_digest, artifacts=(artifact,))\n \n \n def rules():\n", "issue": "Shading throws `NoSuchFileException` given a `deploy_jar` in a subdirectory \n**Describe the bug**\r\nGiven a `deploy_jar` target in a subdirectory shading process throws an exception `NoSuchFileException`\r\n\r\n**Pants version**\r\n2.18.0\r\n\r\n**OS**\r\nUbuntu 22.04\r\n\r\n**Additional info**\r\n`helloworld/HelloWorld.java`:\r\n```java\r\npackage helloworld;\r\n\r\npublic class HelloWorld {\r\n    public static void main(String[] args) {\r\n        System.out.println(\"Hello, World!\");\r\n    }\r\n}\r\n```\r\n`helloworld/BUILD`:\r\n```python\r\njava_sources(name=\"src\")\r\n```\r\n`subdir/BUILD`:\r\n```python\r\ndeploy_jar(\r\n    name=\"fat\",\r\n    main=\"helloworld.HelloWorld\",\r\n    dependencies=[\"//helloworld:src\"],\r\n    shading_rules=[\r\n        shading_keep(pattern=\"helloworld.**\"),\r\n    ],\r\n)\r\n```\r\nIt's important to put deploy_jar into a subdirectory. It works without errors if you put it into root BUILD file.\r\nSteps to reproduce:\r\n- pants generate-lockfiles\r\n- pants subdir:fat\r\n\r\nI get this:\r\n```\r\nProcessExecutionFailure: Process 'Shading JAR subdir/fat.jar' failed with exit code 899.\r\n...\r\njava.nio.file.NoSuchFileException: subdir/fat.jar\r\n...\r\n```\n", "before_files": [{"content": "# Copyright 2021 Pants project contributors (see CONTRIBUTORS.md).\n# Licensed under the Apache License, Version 2.0 (see LICENSE).\n\nimport logging\nfrom dataclasses import dataclass\nfrom pathlib import PurePath\n\nfrom pants.core.goals.package import (\n    BuiltPackage,\n    BuiltPackageArtifact,\n    OutputPathField,\n    PackageFieldSet,\n)\nfrom pants.core.goals.run import RunFieldSet, RunInSandboxBehavior\nfrom pants.engine.addresses import Addresses\nfrom pants.engine.fs import EMPTY_DIGEST, AddPrefix, Digest, MergeDigests\nfrom pants.engine.rules import Get, collect_rules, rule\nfrom pants.engine.target import Dependencies\nfrom pants.engine.unions import UnionRule\nfrom pants.jvm import classpath\nfrom pants.jvm.classpath import Classpath\nfrom pants.jvm.compile import (\n    ClasspathDependenciesRequest,\n    ClasspathEntry,\n    ClasspathEntryRequest,\n    CompileResult,\n    FallibleClasspathEntries,\n    FallibleClasspathEntry,\n)\nfrom pants.jvm.jar_tool.jar_tool import JarToolRequest\nfrom pants.jvm.jar_tool.jar_tool import rules as jar_tool_rules\nfrom pants.jvm.shading.rules import ShadedJar, ShadeJarRequest\nfrom pants.jvm.shading.rules import rules as shaded_jar_rules\nfrom pants.jvm.strip_jar.strip_jar import StripJarRequest\nfrom pants.jvm.subsystems import JvmSubsystem\nfrom pants.jvm.target_types import (\n    DeployJarDuplicatePolicyField,\n    DeployJarExcludeFilesField,\n    DeployJarShadingRulesField,\n    JvmDependenciesField,\n    JvmJdkField,\n    JvmMainClassNameField,\n)\n\nlogger = logging.getLogger(__name__)\n\n\n@dataclass(frozen=True)\nclass DeployJarFieldSet(PackageFieldSet, RunFieldSet):\n    required_fields = (\n        JvmMainClassNameField,\n        JvmJdkField,\n        Dependencies,\n        OutputPathField,\n    )\n    run_in_sandbox_behavior = RunInSandboxBehavior.RUN_REQUEST_HERMETIC\n\n    main_class: JvmMainClassNameField\n    output_path: OutputPathField\n    dependencies: JvmDependenciesField\n    jdk_version: JvmJdkField\n    duplicate_policy: DeployJarDuplicatePolicyField\n    shading_rules: DeployJarShadingRulesField\n    exclude_files: DeployJarExcludeFilesField\n\n\nclass DeployJarClasspathEntryRequest(ClasspathEntryRequest):\n    field_sets = (DeployJarFieldSet,)\n    # A `deploy_jar` can have a Classpath requested for it, but should not be used as a dependency.\n    root_only = True\n\n\n@rule\nasync def deploy_jar_classpath(\n    request: DeployJarClasspathEntryRequest,\n) -> FallibleClasspathEntry:\n    if len(request.component.members) > 1:\n        # If multiple DeployJar targets were coarsened into a single instance, it's because they\n        # formed a cycle among themselves... but at a high level, they shouldn't have dependencies\n        # on one another anyway.\n        raise Exception(\n            \"`deploy_jar` targets should not depend on one another:\\n\"\n            f\"{request.component.bullet_list()}\"\n        )\n    fallible_entries = await Get(FallibleClasspathEntries, ClasspathDependenciesRequest(request))\n    classpath_entries = fallible_entries.if_all_succeeded()\n    if classpath_entries is None:\n        return FallibleClasspathEntry(\n            description=str(request.component),\n            result=CompileResult.DEPENDENCY_FAILED,\n            output=None,\n            exit_code=1,\n        )\n    return FallibleClasspathEntry(\n        description=str(request.component),\n        result=CompileResult.SUCCEEDED,\n        output=ClasspathEntry(EMPTY_DIGEST, dependencies=classpath_entries),\n        exit_code=0,\n    )\n\n\n@rule\nasync def package_deploy_jar(\n    jvm: JvmSubsystem,\n    field_set: DeployJarFieldSet,\n) -> BuiltPackage:\n    \"\"\"\n    Constructs a deploy (\"fat\") JAR file by\n    1. Resolving/compiling a Classpath for the `root_address` target,\n    2. Creating a deploy jar with a valid ZIP index and deduplicated entries\n    3. (optionally) Stripping the jar of all metadata that may cause it to be non-reproducible (https://reproducible-builds.org)\n    4. (optionally) Apply shading rules to the bytecode inside the jar file\n    \"\"\"\n\n    if field_set.main_class.value is None:\n        raise Exception(\"Needs a `main` argument\")\n\n    #\n    # 1. Produce thin JARs containing the transitive classpath\n    #\n\n    classpath = await Get(Classpath, Addresses([field_set.address]))\n    classpath_digest = await Get(Digest, MergeDigests(classpath.digests()))\n\n    #\n    # 2. Use Pants' JAR tool to build a runnable fat JAR\n    #\n\n    output_filename = PurePath(field_set.output_path.value_or_default(file_ending=\"jar\"))\n    jar_digest = await Get(\n        Digest,\n        JarToolRequest(\n            jar_name=output_filename.name,\n            digest=classpath_digest,\n            main_class=field_set.main_class.value,\n            jars=classpath.args(),\n            policies=[\n                (rule.pattern, rule.action)\n                for rule in field_set.duplicate_policy.value_or_default()\n            ],\n            skip=field_set.exclude_files.value,\n            compress=True,\n        ),\n    )\n\n    #\n    # 3. Strip the JAR from  all non-reproducible metadata if requested so\n    #\n    if jvm.reproducible_jars:\n        jar_digest = await Get(\n            Digest,\n            StripJarRequest(\n                digest=jar_digest,\n                filenames=(output_filename.name,),\n            ),\n        )\n\n    #\n    # 4. Apply shading rules\n    #\n    if field_set.shading_rules.value:\n        shaded_jar = await Get(\n            ShadedJar,\n            ShadeJarRequest(\n                path=output_filename,\n                digest=jar_digest,\n                rules=field_set.shading_rules.value,\n                skip_manifest=False,\n            ),\n        )\n        jar_digest = shaded_jar.digest\n\n    prefixed_output_digest = await Get(Digest, AddPrefix(jar_digest, str(output_filename.parent)))\n    artifact = BuiltPackageArtifact(relpath=str(output_filename))\n    return BuiltPackage(digest=prefixed_output_digest, artifacts=(artifact,))\n\n\ndef rules():\n    return [\n        *collect_rules(),\n        *classpath.rules(),\n        *jar_tool_rules(),\n        *shaded_jar_rules(),\n        UnionRule(PackageFieldSet, DeployJarFieldSet),\n        UnionRule(ClasspathEntryRequest, DeployJarClasspathEntryRequest),\n    ]\n", "path": "src/python/pants/jvm/package/deploy_jar.py"}], "after_files": [{"content": "# Copyright 2021 Pants project contributors (see CONTRIBUTORS.md).\n# Licensed under the Apache License, Version 2.0 (see LICENSE).\n\nimport logging\nfrom dataclasses import dataclass\nfrom pathlib import PurePath\n\nfrom pants.core.goals.package import (\n    BuiltPackage,\n    BuiltPackageArtifact,\n    OutputPathField,\n    PackageFieldSet,\n)\nfrom pants.core.goals.run import RunFieldSet, RunInSandboxBehavior\nfrom pants.engine.addresses import Addresses\nfrom pants.engine.fs import EMPTY_DIGEST, AddPrefix, Digest, MergeDigests\nfrom pants.engine.rules import Get, collect_rules, rule\nfrom pants.engine.target import Dependencies\nfrom pants.engine.unions import UnionRule\nfrom pants.jvm import classpath\nfrom pants.jvm.classpath import Classpath\nfrom pants.jvm.compile import (\n    ClasspathDependenciesRequest,\n    ClasspathEntry,\n    ClasspathEntryRequest,\n    CompileResult,\n    FallibleClasspathEntries,\n    FallibleClasspathEntry,\n)\nfrom pants.jvm.jar_tool.jar_tool import JarToolRequest\nfrom pants.jvm.jar_tool.jar_tool import rules as jar_tool_rules\nfrom pants.jvm.shading.rules import ShadedJar, ShadeJarRequest\nfrom pants.jvm.shading.rules import rules as shaded_jar_rules\nfrom pants.jvm.strip_jar.strip_jar import StripJarRequest\nfrom pants.jvm.subsystems import JvmSubsystem\nfrom pants.jvm.target_types import (\n    DeployJarDuplicatePolicyField,\n    DeployJarExcludeFilesField,\n    DeployJarShadingRulesField,\n    JvmDependenciesField,\n    JvmJdkField,\n    JvmMainClassNameField,\n)\n\nlogger = logging.getLogger(__name__)\n\n\n@dataclass(frozen=True)\nclass DeployJarFieldSet(PackageFieldSet, RunFieldSet):\n    required_fields = (\n        JvmMainClassNameField,\n        JvmJdkField,\n        Dependencies,\n        OutputPathField,\n    )\n    run_in_sandbox_behavior = RunInSandboxBehavior.RUN_REQUEST_HERMETIC\n\n    main_class: JvmMainClassNameField\n    output_path: OutputPathField\n    dependencies: JvmDependenciesField\n    jdk_version: JvmJdkField\n    duplicate_policy: DeployJarDuplicatePolicyField\n    shading_rules: DeployJarShadingRulesField\n    exclude_files: DeployJarExcludeFilesField\n\n\nclass DeployJarClasspathEntryRequest(ClasspathEntryRequest):\n    field_sets = (DeployJarFieldSet,)\n    # A `deploy_jar` can have a Classpath requested for it, but should not be used as a dependency.\n    root_only = True\n\n\n@rule\nasync def deploy_jar_classpath(\n    request: DeployJarClasspathEntryRequest,\n) -> FallibleClasspathEntry:\n    if len(request.component.members) > 1:\n        # If multiple DeployJar targets were coarsened into a single instance, it's because they\n        # formed a cycle among themselves... but at a high level, they shouldn't have dependencies\n        # on one another anyway.\n        raise Exception(\n            \"`deploy_jar` targets should not depend on one another:\\n\"\n            f\"{request.component.bullet_list()}\"\n        )\n    fallible_entries = await Get(FallibleClasspathEntries, ClasspathDependenciesRequest(request))\n    classpath_entries = fallible_entries.if_all_succeeded()\n    if classpath_entries is None:\n        return FallibleClasspathEntry(\n            description=str(request.component),\n            result=CompileResult.DEPENDENCY_FAILED,\n            output=None,\n            exit_code=1,\n        )\n    return FallibleClasspathEntry(\n        description=str(request.component),\n        result=CompileResult.SUCCEEDED,\n        output=ClasspathEntry(EMPTY_DIGEST, dependencies=classpath_entries),\n        exit_code=0,\n    )\n\n\n@rule\nasync def package_deploy_jar(\n    jvm: JvmSubsystem,\n    field_set: DeployJarFieldSet,\n) -> BuiltPackage:\n    \"\"\"\n    Constructs a deploy (\"fat\") JAR file by\n    1. Resolving/compiling a Classpath for the `root_address` target,\n    2. Creating a deploy jar with a valid ZIP index and deduplicated entries\n    3. (optionally) Stripping the jar of all metadata that may cause it to be non-reproducible (https://reproducible-builds.org)\n    4. (optionally) Apply shading rules to the bytecode inside the jar file\n    \"\"\"\n\n    if field_set.main_class.value is None:\n        raise Exception(\"Needs a `main` argument\")\n\n    #\n    # 1. Produce thin JARs containing the transitive classpath\n    #\n\n    classpath = await Get(Classpath, Addresses([field_set.address]))\n    classpath_digest = await Get(Digest, MergeDigests(classpath.digests()))\n\n    #\n    # 2. Use Pants' JAR tool to build a runnable fat JAR\n    #\n\n    output_filename = PurePath(field_set.output_path.value_or_default(file_ending=\"jar\"))\n    jar_digest = await Get(\n        Digest,\n        JarToolRequest(\n            jar_name=output_filename.name,\n            digest=classpath_digest,\n            main_class=field_set.main_class.value,\n            jars=classpath.args(),\n            policies=[\n                (rule.pattern, rule.action)\n                for rule in field_set.duplicate_policy.value_or_default()\n            ],\n            skip=field_set.exclude_files.value,\n            compress=True,\n        ),\n    )\n\n    #\n    # 3. Strip the JAR from  all non-reproducible metadata if requested so\n    #\n    if jvm.reproducible_jars:\n        jar_digest = await Get(\n            Digest,\n            StripJarRequest(\n                digest=jar_digest,\n                filenames=(output_filename.name,),\n            ),\n        )\n\n    jar_digest = await Get(Digest, AddPrefix(jar_digest, str(output_filename.parent)))\n\n    #\n    # 4. Apply shading rules\n    #\n    if field_set.shading_rules.value:\n        shaded_jar = await Get(\n            ShadedJar,\n            ShadeJarRequest(\n                path=output_filename,\n                digest=jar_digest,\n                rules=field_set.shading_rules.value,\n                skip_manifest=False,\n            ),\n        )\n        jar_digest = shaded_jar.digest\n\n    artifact = BuiltPackageArtifact(relpath=str(output_filename))\n    return BuiltPackage(digest=jar_digest, artifacts=(artifact,))\n\n\ndef rules():\n    return [\n        *collect_rules(),\n        *classpath.rules(),\n        *jar_tool_rules(),\n        *shaded_jar_rules(),\n        UnionRule(PackageFieldSet, DeployJarFieldSet),\n        UnionRule(ClasspathEntryRequest, DeployJarClasspathEntryRequest),\n    ]\n", "path": "src/python/pants/jvm/package/deploy_jar.py"}]}