On Sep 21, 2009, at 11:20 AM, Adam Murdoch wrote:

Hi,

I'm reworking the API of the various tasks which take source as input, so they can handle our various types such as FileCollection and FileTree. This includes the tasks: Compile, GroovyCompile, ScalaCompile, Javadoc, Groovydoc, Scaladoc, Checkstyle, CodeNarc.

I'd like to keep the ability to keep the ability to use a source directory or set of source directories. So, I'm thinking something like the following, instead of the srcDirs property:

void src(Object... source) // Interprets source as per CopySpec.from (source):

void setSrc(Object source) // Equivalent to discarding all the current source and calling source(source)

FileTree getSrc() // Returns the tree of source.

Plus all the methods on PatternFilterable: include(), exclude(), etc.

Some examples:

compileJava {
src 'src/main/java' // includes all files under $projectDir/src/ main/java src 'src/java/Source1.java', 'src/java/Source2.java' // includes the 2 specified source files
  src ['src/main/java', 'src/Source1.java']
  src source.main.java // all java source in the 'main' source set
  src { javaSrcDirNames.collect { "$srcRoot/$it" } } // 0.7 behaviour

  include 'org/gradle/api/**'
}

and you can do things like:

copy {
  from compileJava.src
  into 'some/dir'
}

Some questions:

- Should we call the method from() instead of src(), to be consistent with the Copy task?

I'm not sure if consistency is that important here as it is a different part of the domain (compared to for example copy/move). src is more expressive I think. On the other hand having 'from' as the standard method to include file elements make our API easy to remember. I'm not sure what the best approach is.


- Do we need the include and exclude methods on these tasks? Source set has them, as does FileTree, so you can do:

source.main.java {
  include 'some/pattern/**'
  exclude 'some/other/pattern/**'
}

or

compileJava {
  src fileTree {
      from 'some/src/dir'
      include 'some/pattern/**'
      exclude 'some/pattern/**'
  }
}


From Gradle 0.8 the source set are the elements that usually should get configured by the user. Normally you do not want to filter just for the compile. You want this filter to be applied also for jar, javadoc, ... This is what the source sets offer. So I think specific compile excludes/includes are a minor use case we should not bloat our API for.

I could not find a way to copy a fileTree. Have I missed something?

- Hans

--
Hans Dockter
Gradle Project Manager
http://www.gradle.org

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email


Reply via email to