com.github.houbie.gradle.lesscss.SourceDirsTask.groovy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of lesscss-gradle-plugin Show documentation
Show all versions of lesscss-gradle-plugin Show documentation
Lesscss is a java wrapper for the JavaScript LESS to CSS compiler
/*
* Copyright (c) 2014 Houbrechts IT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.houbie.gradle.lesscss
import org.gradle.api.file.FileTree
import org.gradle.api.file.FileTreeElement
import org.gradle.api.internal.ConventionTask
import org.gradle.api.specs.Spec
import org.gradle.api.tasks.InputFiles
import org.gradle.api.tasks.SkipWhenEmpty
import org.gradle.api.tasks.util.PatternFilterable
import org.gradle.api.tasks.util.PatternSet
/**
* A {@code SourceDirsTask} performs some operation on files within source directories.
*/
class SourceDirsTask extends ConventionTask implements PatternFilterable {
private final List sourceDirs = []
private final PatternFilterable patternSet = new PatternSet()
/**
* Returns the source for this task, after the include and exclude patterns have been applied to the source directories. Ignores source files which do not exist.
*
* @return The source.
*/
@InputFiles
@SkipWhenEmpty
FileTree getSource() {
project.files(sourceDirs ?: null).getAsFileTree().matching(patternSet)
}
List getSourceDirs() {
sourceDirs.collect { project.file(it) }
}
/**
* Sets the source directory for this task. The given dir object is evaluated as per {@link org.gradle.api.Project#files(Object ...)}.
*
* @param sourceDir The source.
*/
void setSourceDir(Object sourceDir) {
sourceDirs.clear()
sourceDirs << sourceDir
inputs.sourceDir(sourceDir)
}
/**
* Adds some source directories to this task. The given dir objects will be evaluated as per {@link org.gradle.api.Project#files(Object ...)}.
*
* @param sourceDirs The source to add
* @return this
*/
SourceDirsTask sourceDir(Object... sourceDirs) {
for (sourceDir in sourceDirs) {
this.sourceDirs << sourceDir
inputs.sourceDir(sourceDir)
}
return this
}
/**
* {@inheritDoc}
*/
SourceDirsTask include(String... includes) {
patternSet.include(includes)
return this
}
/**
* {@inheritDoc}
*/
SourceDirsTask include(Iterable includes) {
patternSet.include(includes)
return this
}
/**
* {@inheritDoc}
*/
SourceDirsTask include(Spec includeSpec) {
patternSet.include(includeSpec)
return this
}
/**
* {@inheritDoc}
*/
SourceDirsTask include(Closure includeSpec) {
patternSet.include(includeSpec)
return this
}
/**
* {@inheritDoc}
*/
SourceDirsTask exclude(String... excludes) {
patternSet.exclude(excludes)
return this
}
/**
* {@inheritDoc}
*/
SourceDirsTask exclude(Iterable excludes) {
patternSet.exclude(excludes)
return this
}
/**
* {@inheritDoc}
*/
SourceDirsTask exclude(Spec excludeSpec) {
patternSet.exclude(excludeSpec)
return this
}
/**
* {@inheritDoc}
*/
SourceDirsTask exclude(Closure excludeSpec) {
patternSet.exclude(excludeSpec)
return this
}
/**
* {@inheritDoc}
*/
Set getIncludes() {
return patternSet.includes
}
/**
* {@inheritDoc}
*/
SourceDirsTask setIncludes(Iterable includes) {
patternSet.includes = includes
return this
}
/**
* {@inheritDoc}
*/
Set getExcludes() {
return patternSet.excludes
}
/**
* {@inheritDoc}
*/
SourceDirsTask setExcludes(Iterable excludes) {
patternSet.excludes = excludes
return this
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy