in winegrower-extension/winegrower-build/winegrower-maven-plugin/src/main/java/org/apache/winegrower/extension/build/maven/PourMojo.java [165:240]
private Object createConfiguration(final Class<?> configClass)
throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
final Object configuration = configClass.getConstructor().newInstance();
doCall(configuration, "setUseLifecycleCallbacks", new Class<?>[]{boolean.class}, new Object[]{useLifecycleCallbacks});
ofNullable(lifecycleCallbacks).map(it -> it.stream()
.map(clazz -> {
try {
return clazz
.getConstructor()
.newInstance();
} catch (final InstantiationException | NoSuchMethodException | IllegalAccessException e) {
throw new IllegalArgumentException(e);
} catch (final InvocationTargetException e) {
throw new IllegalArgumentException(
e.getTargetException());
}
})
.collect(toList()))
.ifPresent(value -> doCall(configuration, "setLifecycleCallbacks", new Class<?>[]{List.class}, new Object[]{value}));
ofNullable(workDir)
.ifPresent(value -> doCall(configuration, "setWorkDir", new Class<?>[]{File.class}, new Object[]{value}));
ofNullable(prioritizedBundles)
.filter(it -> !it.isEmpty())
.map(it -> it.stream().filter(v -> !"empty".equals(v)).collect(toList()))
.ifPresent(value -> doCall(configuration, "setPrioritizedBundles", new Class<?>[]{List.class}, new Object[]{value}));
ofNullable(ignoredBundles)
.ifPresent(value -> doCall(configuration, "setIgnoredBundles", new Class<?>[]{Collection.class}, new Object[]{value}));
ofNullable(scanningIncludes)
.ifPresent(value -> doCall(configuration, "setScanningIncludes", new Class<?>[]{Collection.class}, new Object[]{value}));
ofNullable(scanningExcludes)
.ifPresent(value -> doCall(configuration, "setScanningExcludes", new Class<?>[]{Collection.class}, new Object[]{value}));
ofNullable(manifestContributors)
.filter(it -> !it.isEmpty())
.ifPresent(contributors -> {
try {
final Class<?> type = Thread.currentThread().getContextClassLoader().loadClass(
"org.apache.winegrower.scanner.manifest.ManifestContributor");
final Collection<?> value = contributors.stream()
.filter(it -> !"empty".equals(it))
.map(clazz -> {
try {
return Thread.currentThread()
.getContextClassLoader()
.loadClass(clazz)
.getConstructor()
.newInstance();
} catch (final InstantiationException | NoSuchMethodException | IllegalAccessException | ClassNotFoundException e) {
throw new IllegalArgumentException(e);
} catch (final InvocationTargetException e) {
throw new IllegalArgumentException(
e.getTargetException());
}
})
.map(type::cast)
.collect(toList());
doCall(configuration, "setManifestContributors", new Class<?>[]{Collection.class}, new Object[]{value});
} catch (final ClassNotFoundException e) {
throw new IllegalArgumentException(e);
}
});
ofNullable(jarFilter)
.map(String::valueOf)
.filter(it -> !it.isEmpty())
.ifPresent(filter -> {
try {
final Predicate<String> predicate = (Predicate<String>) Thread.currentThread()
.getContextClassLoader().loadClass(filter).getConstructor().newInstance();
doCall(configuration, "setJarFilter", new Class<?>[]{Predicate.class}, new Object[]{predicate});
} catch (final InstantiationException | NoSuchMethodException | IllegalAccessException | ClassNotFoundException e) {
throw new IllegalArgumentException(e);
} catch (final InvocationTargetException e) {
throw new IllegalArgumentException(e.getTargetException());
}
});
return configuration;
}