public WorkResult copy(Closure closure) {
   FileCopyAction copyAction = new FileCopyAction(instantiator, resolver);
   CopySpecInternal copySpec = copyAction.getCopySpec();
   copySpec.from(this);
   ConfigureUtil.configure(closure, copySpec);
   return copyAction.copy();
 }
  public ArtifactRepository createRepository(Object userDescription) {
    if (userDescription instanceof ArtifactRepository) {
      return (ArtifactRepository) userDescription;
    }

    if (userDescription instanceof String) {
      MavenArtifactRepository repository = createMavenRepository();
      repository.setUrl(userDescription);
      return repository;
    } else if (userDescription instanceof Map) {
      Map<String, ?> userDescriptionMap = (Map<String, ?>) userDescription;
      MavenArtifactRepository repository = createMavenRepository();
      ConfigureUtil.configureByMap(userDescriptionMap, repository);
      return repository;
    }

    DependencyResolver result;
    if (userDescription instanceof DependencyResolver) {
      result = (DependencyResolver) userDescription;
    } else {
      throw new InvalidUserDataException(
          String.format("Cannot create a DependencyResolver instance from %s", userDescription));
    }
    return new CustomResolverArtifactRepository(
        result, progressLoggerFactory, localCacheManager, downloadingCacheManager);
  }
Beispiel #3
0
  /**
   * Configures the manifest for this JAR archive.
   *
   * <p>The given closure is executed to configure the manifest. The {@link
   * org.gradle.api.java.archives.Manifest} is passed to the closure as its delegate.
   *
   * @param configureClosure The closure.
   * @return This.
   */
  public Jar manifest(Closure<?> configureClosure) {
    if (getManifest() == null) {
      manifest = new DefaultManifest(((ProjectInternal) getProject()).getFileResolver());
    }

    ConfigureUtil.configure(configureClosure, getManifest());
    return this;
  }
 @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);
   }
 }
 public DefaultConfigurableFileTree(
     Map<String, ?> args,
     FileResolver resolver,
     TaskResolver taskResolver,
     Instantiator instantiator) {
   this.resolver = resolver != null ? resolver : new IdentityFileResolver();
   ConfigureUtil.configureByMap(args, this);
   buildDependency = new DefaultTaskDependency(taskResolver);
   this.instantiator = instantiator;
 }
Beispiel #6
0
 public CopySpec from(Object sourcePath, Closure c) {
   if (c == null) {
     from(sourcePath);
     return this;
   } else {
     CopySpecImpl child = addChild();
     child.from(sourcePath);
     ConfigureUtil.configure(c, child);
     return child;
   }
 }
Beispiel #7
0
 public CopySpecImpl into(Object destPath, Closure configureClosure) {
   if (configureClosure == null) {
     into(destPath);
     return this;
   } else {
     CopySpecImpl child = addChild();
     child.into(destPath);
     ConfigureUtil.configure(configureClosure, child);
     return child;
   }
 }
Beispiel #8
0
  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;
  }
  public ArtifactRepository createRepository(Object userDescription) {
    if (userDescription instanceof ArtifactRepository) {
      return (ArtifactRepository) userDescription;
    }

    if (userDescription instanceof String) {
      MavenArtifactRepository repository = createMavenRepository();
      repository.setUrl(userDescription);
      return repository;
    } else if (userDescription instanceof Map) {
      Map<String, ?> userDescriptionMap = (Map<String, ?>) userDescription;
      MavenArtifactRepository repository = createMavenRepository();
      ConfigureUtil.configureByMap(userDescriptionMap, repository);
      return repository;
    }

    if (userDescription instanceof DependencyResolver) {
      return legacyDependencyResolverRepositoryFactory.createRepository(
          (DependencyResolver) userDescription);
    }
    throw new InvalidUserDataException(
        String.format("Cannot create a DependencyResolver instance from %s", userDescription));
  }
 public DefaultCppSourceSet source(Closure closure) {
   ConfigureUtil.configure(closure, source);
   return this;
 }
Beispiel #11
0
 public void repositories(Closure configureClosure) {
   ConfigureUtil.configure(configureClosure, repositoryHandler);
 }
 public DefaultCppSourceSet exportedHeaders(Closure closure) {
   ConfigureUtil.configure(closure, exportedHeaders);
   return this;
 }
Beispiel #13
0
 /**
  * Adds content to this JAR archive's META-INF directory.
  *
  * <p>The given closure is executed to configure a {@code CopySpec}. The {@link
  * org.gradle.api.file.CopySpec} is passed to the closure as its delegate.
  *
  * @param configureClosure The closure.
  * @return The created {@code CopySpec}
  */
 public CopySpec metaInf(Closure<?> configureClosure) {
   return ConfigureUtil.configure(configureClosure, getMetaInf());
 }
Beispiel #14
0
 public void dependencies(Closure configureClosure) {
   ConfigureUtil.configure(configureClosure, dependencyHandler);
 }
Beispiel #15
0
 /**
  * Enables advanced configuration like tinkering with the output XML or affecting the way that the
  * contents of an existing .classpath file is merged with Gradle build information. The object
  * passed to the whenMerged{} and beforeMerged{} closures is of type {@link Classpath}.
  *
  * <p>See {@link EclipseProject} for an example.
  */
 public void file(Closure closure) {
   ConfigureUtil.configure(closure, file);
 }
Beispiel #16
0
 /**
  * Allows configuring the logging of the test execution, for example log eagerly the standard
  * output, etc.
  *
  * <pre autoTested=''>
  * apply plugin: 'java'
  *
  * //makes the standard streams (err and out) visible at console when running tests
  * test.testLogging {
  *   showStandardStreams = true
  * }
  * </pre>
  *
  * @param closure configure closure
  */
 public void testLogging(Closure closure) {
   ConfigureUtil.configure(closure, testLogging);
 }
Beispiel #17
0
 /**
  * Configured the credentials to be used when cloning the repo. This will be passed a {@link
  * PasswordCredentials} instance.
  *
  * @param closure the configuration closure
  */
 @SuppressWarnings("rawtypes")
 public void credentials(Closure closure) {
   ConfigureUtil.configure(closure, getCredentials());
 }
 public T getByName(String name, Closure configureClosure) throws UnknownDomainObjectException {
   T t = getByName(name);
   ConfigureUtil.configure(configureClosure, t);
   return t;
 }
 public void layout(String layoutName, Closure config) {
   layout(layoutName);
   ConfigureUtil.configure(config, layout);
 }
 public void execute(Object o) {
   ConfigureUtil.configure(cl, o);
 }
Beispiel #21
0
 public TestFrameworkOptions options(Closure testFrameworkConfigure) {
   TestFrameworkOptions options = getTestFramework().getOptions();
   ConfigureUtil.configure(testFrameworkConfigure, testFramework.getOptions());
   return options;
 }