org.gradle.util.ConfigureUtil Java Examples

The following examples show how to use org.gradle.util.ConfigureUtil. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DefaultRepositoryHandler.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public DependencyResolver mavenRepo(Map<String, ?> args, Closure configClosure) {
    DeprecationLogger.nagUserOfReplacedMethod("RepositoryHandler.mavenRepo()", "maven()");
    Map<String, Object> modifiedArgs = new HashMap<String, Object>(args);
    if (modifiedArgs.containsKey("urls")) {
        List<?> urls = flattenCollections(modifiedArgs.remove("urls"));
        if (!urls.isEmpty()) {
            modifiedArgs.put("url", urls.get(0));
            List<?> extraUrls = urls.subList(1, urls.size());
            modifiedArgs.put("artifactUrls", extraUrls);
        }
    }

    MavenArtifactRepository repository = repositoryFactory.createMavenRepository();
    ConfigureUtil.configureByMap(modifiedArgs, repository);
    DependencyResolver resolver = repositoryFactory.toResolver(repository);
    ConfigureUtil.configure(configClosure, resolver);
    addRepository(repositoryFactory.createResolverBackedRepository(resolver), "mavenRepo");
    return resolver;
}
 
Example #2
Source File: FilterChain.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public void add(final Class<? extends FilterReader> filterType, final Map<String, ?> properties) {
    transformers.add(new Transformer<Reader, Reader>() {
        public Reader transform(Reader original) {
            try {
                Constructor<? extends FilterReader> constructor = filterType.getConstructor(Reader.class);
                FilterReader result = constructor.newInstance(original);

                if (properties != null) {
                    ConfigureUtil.configureByMap(properties, result);
                }
                return result;
            } catch (Throwable th) {
                throw new InvalidUserDataException("Error - Invalid filter specification for " + filterType.getName(), th);
            }
        }
    });
}
 
Example #3
Source File: FilterChain.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public void add(final Class<? extends FilterReader> filterType, final Map<String, ?> properties) {
    transformers.add(new Transformer<Reader, Reader>() {
        public Reader transform(Reader original) {
            try {
                Constructor<? extends FilterReader> constructor = filterType.getConstructor(Reader.class);
                FilterReader result = constructor.newInstance(original);

                if (properties != null) {
                    ConfigureUtil.configureByMap(properties, result);
                }
                return result;
            } catch (Throwable th) {
                throw new InvalidUserDataException("Error - Invalid filter specification for " + filterType.getName(), th);
            }
        }
    });
}
 
Example #4
Source File: DefaultNamedDomainObjectCollection.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public Object invokeMethod(String name, Object... arguments) throws groovy.lang.MissingMethodException {
    if (isConfigureMethod(name, arguments)) {
        return ConfigureUtil.configure((Closure) arguments[0], getByName(name));
    } else {
        return super.invokeMethod(name, arguments);
    }
}
 
Example #5
Source File: DefaultCopySpec.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public CopySpec into(Object destPath, Closure configureClosure) {
    if (configureClosure == null) {
        into(destPath);
        return this;
    } else {
        CopySpecInternal child = addChild();
        child.into(destPath);
        return ConfigureUtil.configure(configureClosure, instantiator.newInstance(CopySpecWrapper.class, child));
    }
}
 
Example #6
Source File: DefaultConfigurableFileTree.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public WorkResult copy(final Closure closure) {
    return fileCopier.copy(new Action<CopySpec>() {
        public void execute(CopySpec copySpec) {
            copySpec.from(DefaultConfigurableFileTree.this);
            ConfigureUtil.configure(closure, copySpec);
        }
    });
}
 
Example #7
Source File: Test.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private TestFramework useTestFramework(TestFramework testFramework, Closure testFrameworkConfigure) {
    if (testFramework == null) {
        throw new IllegalArgumentException("testFramework is null!");
    }

    this.testFramework = testFramework;

    if (testFrameworkConfigure != null) {
        ConfigureUtil.configure(testFrameworkConfigure, this.testFramework.getOptions());
    }

    return this.testFramework;
}
 
Example #8
Source File: DefaultCopySpec.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public CopySpec into(Object destPath, Closure configureClosure) {
    if (configureClosure == null) {
        into(destPath);
        return this;
    } else {
        CopySpecInternal child = addChild();
        child.into(destPath);
        return ConfigureUtil.configure(configureClosure, instantiator.newInstance(CopySpecWrapper.class, child));
    }
}
 
Example #9
Source File: AbstractPolymorphicDomainObjectContainer.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public Object invokeMethod(String name, Object... arguments) throws groovy.lang.MissingMethodException {
    if (isConfigureMethod(name, arguments)) {
        T element = getByName(name);
        Object lastArgument = arguments[arguments.length - 1];
        if (lastArgument instanceof Closure) {
            ConfigureUtil.configure((Closure) lastArgument, element);
        }
        return element;
    } else {
        return super.invokeMethod(name, arguments);
    }
}
 
Example #10
Source File: DefaultCopySpec.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public CopySpec into(Object destPath, Closure configureClosure) {
    if (configureClosure == null) {
        into(destPath);
        return this;
    } else {
        CopySpecInternal child = addChild();
        child.into(destPath);
        return ConfigureUtil.configure(configureClosure, instantiator.newInstance(CopySpecWrapper.class, child));
    }
}
 
Example #11
Source File: Test.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private TestFramework useTestFramework(TestFramework testFramework, Closure testFrameworkConfigure) {
    if (testFramework == null) {
        throw new IllegalArgumentException("testFramework is null!");
    }

    this.testFramework = testFramework;

    if (testFrameworkConfigure != null) {
        ConfigureUtil.configure(testFrameworkConfigure, this.testFramework.getOptions());
    }

    return this.testFramework;
}
 
Example #12
Source File: DefaultCopySpec.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public CopySpec from(Object sourcePath, Closure c) {
    if (c == null) {
        from(sourcePath);
        return this;
    } else {
        CopySpecInternal child = addChild();
        child.from(sourcePath);
        return ConfigureUtil.configure(c, instantiator.newInstance(CopySpecWrapper.class, child));
    }
}
 
Example #13
Source File: DefaultCopySpec.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public CopySpec from(Object sourcePath, Closure c) {
    if (c == null) {
        from(sourcePath);
        return this;
    } else {
        CopySpecInternal child = addChild();
        child.from(sourcePath);
        return ConfigureUtil.configure(c, instantiator.newInstance(CopySpecWrapper.class, child));
    }
}
 
Example #14
Source File: DefaultConfigurableFileTree.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public WorkResult copy(final Closure closure) {
    return fileCopier.copy(new Action<CopySpec>() {
        public void execute(CopySpec copySpec) {
            copySpec.from(DefaultConfigurableFileTree.this);
            ConfigureUtil.configure(closure, copySpec);
        }
    });
}
 
Example #15
Source File: DefaultCopySpec.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public CopySpec from(Object sourcePath, Closure c) {
    if (c == null) {
        from(sourcePath);
        return this;
    } else {
        CopySpecInternal child = addChild();
        child.from(sourcePath);
        return ConfigureUtil.configure(c, instantiator.newInstance(CopySpecWrapper.class, child));
    }
}
 
Example #16
Source File: DefaultManifest.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public DefaultManifest from(Object mergePaths, Closure<?> closure) {
    DefaultManifestMergeSpec mergeSpec = new DefaultManifestMergeSpec();
    mergeSpec.from(mergePaths);
    manifestMergeSpecs.add(mergeSpec);
    ConfigureUtil.configure(closure, mergeSpec);
    return this;
}
 
Example #17
Source File: AbstractTask.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public Task configure(Closure closure) {
    return ConfigureUtil.configure(closure, this, false);
}
 
Example #18
Source File: DefaultSourceSet.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public SourceSet resources(Closure configureClosure) {
    ConfigureUtil.configure(configureClosure, getResources());
    return this;
}
 
Example #19
Source File: DefaultSourceSet.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public SourceSet java(Closure configureClosure) {
    ConfigureUtil.configure(configureClosure, getJava());
    return this;
}
 
Example #20
Source File: AbstractPluginAware.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void apply(Closure closure) {
    DefaultObjectConfigurationAction action = new DefaultObjectConfigurationAction(getFileResolver(), getScriptPluginFactory(), getScriptHandlerFactory(), getClassLoaderScope().getBase().createChild(), this);
    ConfigureUtil.configure(closure, action);
    action.execute();
}
 
Example #21
Source File: BasePomFilterContainer.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public MavenPom pom(Closure configureClosure) {
    return ConfigureUtil.configure(configureClosure, getPom());
}
 
Example #22
Source File: DefaultSourceSet.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public SourceSet resources(Closure configureClosure) {
    ConfigureUtil.configure(configureClosure, getResources());
    return this;
}
 
Example #23
Source File: DefaultGroovySourceSet.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public GroovySourceSet groovy(Closure configureClosure) {
    ConfigureUtil.configure(configureClosure, getGroovy());
    return this;
}
 
Example #24
Source File: DefaultGroovySourceSet.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public GroovySourceSet groovy(Closure configureClosure) {
    ConfigureUtil.configure(configureClosure, getGroovy());
    return this;
}
 
Example #25
Source File: DefaultArtifactRepositoryContainer.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public DefaultArtifactRepositoryContainer configure(Closure closure) {
    return ConfigureUtil.configure(closure, this, false);
}
 
Example #26
Source File: DefaultAspectjSourceSet.java    From gradle-plugins with MIT License 4 votes vote down vote up
@Override
public AspectjSourceSet aspectj(@Nullable Closure configureClosure) {
    ConfigureUtil.configure(configureClosure, getAspectj());
    return this;
}
 
Example #27
Source File: DefaultScript.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public ConfigurableFileCollection files(Object paths, Closure configureClosure) {
    return ConfigureUtil.configure(configureClosure, fileOperations.files(paths));
}
 
Example #28
Source File: DefaultScript.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void apply(Map options) {
    DefaultObjectConfigurationAction action = createObjectConfigurationAction();
    ConfigureUtil.configureByMap(options, action);
    action.execute();
}
 
Example #29
Source File: DefaultScript.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void apply(Closure closure) {
    DefaultObjectConfigurationAction action = createObjectConfigurationAction();
    ConfigureUtil.configure(closure, action);
    action.execute();
}
 
Example #30
Source File: AbstractProject.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void artifacts(Closure configureClosure) {
    ConfigureUtil.configure(configureClosure, getArtifacts());
}