@@ -112,6 +112,16 @@ interface WithInitialization extends Plugin {
112112 Map <TypeDescription , byte []> initialize (ClassFileLocator classFileLocator );
113113 }
114114
115+ interface WithClassPath extends Plugin {
116+
117+ /**
118+ * Provides the classPath elements from the {@link Plugin.Engine}.
119+ *
120+ * @param elements The classPath elements
121+ */
122+ void processClassPath (Iterable <File > elements );
123+ }
124+
115125 /**
116126 * A factory for providing a build plugin.
117127 */
@@ -872,6 +882,14 @@ interface Engine {
872882 */
873883 Engine ignore (ElementMatcher <? super TypeDescription > matcher );
874884
885+ /**
886+ * Appends the classPath elements to the Engine.
887+ *
888+ * @param elements The classPath elements
889+ * @return A new plugin engine that is equal to this engine but with the supplied classpath elements.
890+ */
891+ Engine withClassPath (Iterable <File > elements );
892+
875893 /**
876894 * Applies this plugin engine onto a given source and target.
877895 *
@@ -4659,6 +4677,11 @@ class Default extends AbstractBase {
46594677 */
46604678 private final ElementMatcher .Junction <? super TypeDescription > ignoredTypeMatcher ;
46614679
4680+ /**
4681+ * The classPath elements.
4682+ */
4683+ private final Iterable <File > classPath ;
4684+
46624685 /**
46634686 * Creates a new default plugin engine that rebases types and fails fast and on unresolved types and on live initializers.
46644687 */
@@ -4692,7 +4715,8 @@ protected Default(ByteBuddy byteBuddy, TypeStrategy typeStrategy) {
46924715 ErrorHandler .Enforcing .ALL_TYPES_RESOLVED ,
46934716 ErrorHandler .Enforcing .NO_LIVE_INITIALIZERS ),
46944717 Dispatcher .ForSerialTransformation .Factory .INSTANCE ,
4695- none ());
4718+ none (),
4719+ new ArrayList <File >());
46964720 }
46974721
46984722 /**
@@ -4707,6 +4731,7 @@ protected Default(ByteBuddy byteBuddy, TypeStrategy typeStrategy) {
47074731 * @param errorHandler The error handler to use.
47084732 * @param dispatcherFactory The dispatcher factory to use.
47094733 * @param ignoredTypeMatcher A matcher for types to exclude from transformation.
4734+ * @param classPath The classPath elements.
47104735 */
47114736 protected Default (ByteBuddy byteBuddy ,
47124737 TypeStrategy typeStrategy ,
@@ -4716,7 +4741,8 @@ protected Default(ByteBuddy byteBuddy,
47164741 Listener listener ,
47174742 ErrorHandler errorHandler ,
47184743 Dispatcher .Factory dispatcherFactory ,
4719- ElementMatcher .Junction <? super TypeDescription > ignoredTypeMatcher ) {
4744+ ElementMatcher .Junction <? super TypeDescription > ignoredTypeMatcher ,
4745+ Iterable <File > classPath ) {
47204746 this .byteBuddy = byteBuddy ;
47214747 this .typeStrategy = typeStrategy ;
47224748 this .poolStrategy = poolStrategy ;
@@ -4726,6 +4752,7 @@ protected Default(ByteBuddy byteBuddy,
47264752 this .errorHandler = errorHandler ;
47274753 this .dispatcherFactory = dispatcherFactory ;
47284754 this .ignoredTypeMatcher = ignoredTypeMatcher ;
4755+ this .classPath = classPath ;
47294756 }
47304757
47314758 /**
@@ -4796,7 +4823,8 @@ public Engine with(ByteBuddy byteBuddy) {
47964823 listener ,
47974824 errorHandler ,
47984825 dispatcherFactory ,
4799- ignoredTypeMatcher );
4826+ ignoredTypeMatcher ,
4827+ classPath );
48004828 }
48014829
48024830 /**
@@ -4811,7 +4839,8 @@ public Engine with(TypeStrategy typeStrategy) {
48114839 listener ,
48124840 errorHandler ,
48134841 dispatcherFactory ,
4814- ignoredTypeMatcher );
4842+ ignoredTypeMatcher ,
4843+ classPath );
48154844 }
48164845
48174846 /**
@@ -4826,7 +4855,8 @@ public Engine with(PoolStrategy poolStrategy) {
48264855 listener ,
48274856 errorHandler ,
48284857 dispatcherFactory ,
4829- ignoredTypeMatcher );
4858+ ignoredTypeMatcher ,
4859+ classPath );
48304860 }
48314861
48324862 /**
@@ -4841,7 +4871,8 @@ public Engine with(ClassFileLocator classFileLocator) {
48414871 listener ,
48424872 errorHandler ,
48434873 dispatcherFactory ,
4844- ignoredTypeMatcher );
4874+ ignoredTypeMatcher ,
4875+ classPath );
48454876 }
48464877
48474878 /**
@@ -4856,7 +4887,8 @@ public Engine with(@MaybeNull ClassFileVersion classFileVersion) {
48564887 listener ,
48574888 errorHandler ,
48584889 dispatcherFactory ,
4859- ignoredTypeMatcher );
4890+ ignoredTypeMatcher ,
4891+ classPath );
48604892 }
48614893
48624894 /**
@@ -4871,7 +4903,8 @@ public Engine with(Listener listener) {
48714903 new Listener .Compound (this .listener , listener ),
48724904 errorHandler ,
48734905 dispatcherFactory ,
4874- ignoredTypeMatcher );
4906+ ignoredTypeMatcher ,
4907+ classPath );
48754908 }
48764909
48774910 /**
@@ -4886,7 +4919,8 @@ public Engine withoutErrorHandlers() {
48864919 listener ,
48874920 Listener .NoOp .INSTANCE ,
48884921 dispatcherFactory ,
4889- ignoredTypeMatcher );
4922+ ignoredTypeMatcher ,
4923+ classPath );
48904924 }
48914925
48924926 /**
@@ -4901,7 +4935,8 @@ public Engine withErrorHandlers(List<? extends ErrorHandler> errorHandlers) {
49014935 listener ,
49024936 new ErrorHandler .Compound (errorHandlers ),
49034937 dispatcherFactory ,
4904- ignoredTypeMatcher );
4938+ ignoredTypeMatcher ,
4939+ classPath );
49054940 }
49064941
49074942 /**
@@ -4916,7 +4951,8 @@ public Engine with(Dispatcher.Factory dispatcherFactory) {
49164951 listener ,
49174952 errorHandler ,
49184953 dispatcherFactory ,
4919- ignoredTypeMatcher );
4954+ ignoredTypeMatcher ,
4955+ classPath );
49204956 }
49214957
49224958 /**
@@ -4931,7 +4967,21 @@ public Engine ignore(ElementMatcher<? super TypeDescription> matcher) {
49314967 listener ,
49324968 errorHandler ,
49334969 dispatcherFactory ,
4934- ignoredTypeMatcher .<TypeDescription >or (matcher ));
4970+ ignoredTypeMatcher .<TypeDescription >or (matcher ),
4971+ classPath );
4972+ }
4973+
4974+ public Engine withClassPath (Iterable <File > elements ) {
4975+ return new Default (byteBuddy ,
4976+ typeStrategy ,
4977+ poolStrategy ,
4978+ classFileLocator ,
4979+ classFileVersion ,
4980+ listener ,
4981+ errorHandler ,
4982+ dispatcherFactory ,
4983+ ignoredTypeMatcher ,
4984+ elements );
49354985 }
49364986
49374987 /**
@@ -4946,6 +4996,7 @@ public Summary apply(Source source, Target target, List<? extends Plugin.Factory
49464996 List <Plugin > plugins = new ArrayList <Plugin >(factories .size ());
49474997 List <WithInitialization > initializers = new ArrayList <WithInitialization >();
49484998 List <WithPreprocessor > preprocessors = new ArrayList <WithPreprocessor >();
4999+ List <WithClassPath > classPathers = new ArrayList <WithClassPath >();
49495000 try {
49505001 for (Plugin .Factory factory : factories ) {
49515002 Plugin plugin = factory .make ();
@@ -4956,6 +5007,9 @@ public Summary apply(Source source, Target target, List<? extends Plugin.Factory
49565007 if (plugin instanceof WithInitialization ) {
49575008 initializers .add ((WithInitialization ) plugin );
49585009 }
5010+ if (plugin instanceof WithClassPath ) {
5011+ classPathers .add ((WithClassPath ) plugin );
5012+ }
49595013 }
49605014 Source .Origin origin = source .read ();
49615015 try {
@@ -4965,6 +5019,9 @@ public Summary apply(Source source, Target target, List<? extends Plugin.Factory
49655019 listener .onManifest (manifest );
49665020 Target .Sink sink = target .write (manifest );
49675021 try {
5022+ for (WithClassPath classPather : classPathers ) {
5023+ classPather .processClassPath (classPath );
5024+ }
49685025 for (WithInitialization initializer : initializers ) {
49695026 sink .store (initializer .initialize (classFileLocator ));
49705027 }
0 commit comments