@@ -3713,13 +3713,26 @@ class ForFolder implements Target, Sink {
37133713 */
37143714 private final File folder ;
37153715
3716+ private final boolean link ;
3717+
37163718 /**
37173719 * Creates a new target for a folder.
37183720 *
37193721 * @param folder The folder that is represented by this instance.
37203722 */
37213723 public ForFolder (File folder ) {
3724+ this (folder , false );
3725+ }
3726+
3727+ /**
3728+ * Creates a new target for a folder.
3729+ *
3730+ * @param folder The folder that is represented by this instance.
3731+ * @param link {@code true} if retained files should be linked and not copied.
3732+ */
3733+ public ForFolder (File folder , boolean link ) {
37223734 this .folder = folder ;
3735+ this .link = link ;
37233736 }
37243737
37253738 /**
@@ -3789,7 +3802,11 @@ public void retain(Source.Element element) throws IOException {
37893802 } else if (!target .getParentFile ().isDirectory () && !target .getParentFile ().mkdirs ()) {
37903803 throw new IOException ("Could not create directory: " + target .getParent ());
37913804 } else if (resolved != null && !resolved .equals (target )) {
3792- FileSystem .getInstance ().copy (resolved , target );
3805+ if (link ) {
3806+ FileSystem .getInstance ().link (resolved , target );
3807+ } else {
3808+ FileSystem .getInstance ().copy (resolved , target );
3809+ }
37933810 } else if (!target .equals (resolved )) {
37943811 InputStream inputStream = element .getInputStream ();
37953812 try {
@@ -3889,7 +3906,7 @@ interface Materializable {
38893906 void materialize (Target .Sink sink ,
38903907 List <TypeDescription > transformed ,
38913908 Map <TypeDescription ,
3892- List <Throwable >> failed ,
3909+ List <Throwable >> failed ,
38933910 List <String > unresolved ) throws IOException ;
38943911
38953912 /**
@@ -3925,7 +3942,7 @@ protected ForTransformedElement(@MaybeNull ClassFileVersion classFileVersion, Dy
39253942 public void materialize (Target .Sink sink ,
39263943 List <TypeDescription > transformed ,
39273944 Map <TypeDescription ,
3928- List <Throwable >> failed ,
3945+ List <Throwable >> failed ,
39293946 List <String > unresolved ) throws IOException {
39303947 if (classFileVersion == null ) {
39313948 sink .store (dynamicType .getAllTypes ());
@@ -3961,7 +3978,7 @@ protected ForRetainedElement(Source.Element element) {
39613978 public void materialize (Target .Sink sink ,
39623979 List <TypeDescription > transformed ,
39633980 Map <TypeDescription ,
3964- List <Throwable >> failed ,
3981+ List <Throwable >> failed ,
39653982 List <String > unresolved ) throws IOException {
39663983 sink .retain (element );
39673984 }
@@ -4006,7 +4023,7 @@ protected ForFailedElement(Source.Element element, TypeDescription typeDescripti
40064023 public void materialize (Target .Sink sink ,
40074024 List <TypeDescription > transformed ,
40084025 Map <TypeDescription ,
4009- List <Throwable >> failed ,
4026+ List <Throwable >> failed ,
40104027 List <String > unresolved ) throws IOException {
40114028 sink .retain (element );
40124029 failed .put (typeDescription , errored );
@@ -4045,7 +4062,7 @@ protected ForUnresolvedElement(Source.Element element, String typeName) {
40454062 public void materialize (Target .Sink sink ,
40464063 List <TypeDescription > transformed ,
40474064 Map <TypeDescription ,
4048- List <Throwable >> failed ,
4065+ List <Throwable >> failed ,
40494066 List <String > unresolved ) throws IOException {
40504067 sink .retain (element );
40514068 unresolved .add (typeName );
0 commit comments