public static void createXdepsDependencyConfiguration(Project project) { Configuration xdeps; try { xdeps = project.getConfigurations().getByName("xdeps"); } catch (UnknownConfigurationException e) { xdeps = project.getConfigurations().create("xdeps"); } // https://docs.gradle.org/current/userguide/dependency_management.html#sub:dynamic_versions_and_changing_modules xdeps.getResolutionStrategy().cacheChangingModulesFor(0, TimeUnit.SECONDS); }
@Override protected UnknownDomainObjectException createNotFoundException(String name) { return new UnknownConfigurationException(String.format("Configuration with name '%s' not found.", name)); }
private void fixConfig() { final Project project = getProject(); // defaults if (classpath == null) { try { classpath.add(project.getConfigurations().getByName(TomEEEmbeddedExtension.ALIAS).fileCollection()); } catch (final UnknownConfigurationException uce) { classpath = project.getConfigurations().getByName(TomEEEmbeddedExtension.NAME); } } if (docBase == null) { docBase = new File(project.getProjectDir(), "src/main/webapp"); } if (workDir == null) { workDir = new File(project.getBuildDir(), "tomee-embedded/work"); } if (dir == null) { dir = new File(project.getBuildDir(), "tomee-embedded/run").getAbsolutePath(); } if (modules == null || modules.isEmpty()) { final File main = new File(project.getBuildDir(), "classes/main"); if (main.isDirectory()) { modules = new ArrayList<>(singletonList(main)); } } // extension override for (final String name : asList(TomEEEmbeddedExtension.NAME, TomEEEmbeddedExtension.ALIAS)) { final TomEEEmbeddedExtension extension = TomEEEmbeddedExtension.class.cast(project.getExtensions().findByName(name)); if (extension != null) { for (final Field f : TomEEEmbeddedTask.class.getDeclaredFields()) { if (f.isAnnotationPresent(Input.class)) { try { final Field extField = TomEEEmbeddedExtension.class.getDeclaredField(f.getName()); if (!extField.isAccessible()) { extField.setAccessible(true); } final Object val = extField.get(extension); if (val != null) { if (!f.isAccessible()) { f.setAccessible(true); } f.set(this, val); } } catch (final IllegalAccessException | NoSuchFieldException e) { getLogger().warn("No field " + f.getName() + " in " + extension, e); } } } } } }
ConfigurationInternal getByName(String name) throws UnknownConfigurationException;