All Downloads are FREE. Search and download functionalities are using the official Maven repository.

flair.gradle.tasks.process.ProcessClasses.groovy Maven / Gradle / Ivy

package flair.gradle.tasks.process

import flair.gradle.dependencies.Config
import flair.gradle.tasks.AbstractVariantTask
import flair.gradle.tasks.TaskGroup
import flair.gradle.variants.Variant
import org.gradle.api.tasks.InputFiles
import org.gradle.api.tasks.OutputDirectory
import org.gradle.api.tasks.TaskAction

/**
 * @author SamYStudiO ( [email protected] )
 */
class ProcessClasses extends AbstractVariantTask
{
	@InputFiles
	def Set inputFiles

	@OutputDirectory
	def File outputDir

	@Override
	public void setVariant( Variant variant )
	{
		super.variant = variant

		inputFiles = findInputFiles( )
		outputDir = project.file( "${ outputVariantDir }/classes" )
	}

	public ProcessClasses()
	{
		group = TaskGroup.DEFAULT.name
		description = ""
	}

	@TaskAction
	public void processClasses()
	{
		outputDir.deleteDir( )

		inputFiles.each { file ->

			if( file.exists( ) )
			{
				project.copy {
					from file
					into "${ outputVariantDir }/classes"
				}
			}
		}
	}

	private Set findInputFiles()
	{
		List list = new ArrayList( )

		variant.directoriesCapitalized.each {

			String s = it == "main" ? Config.SOURCE.name : it + Config.SOURCE.name.capitalize( )

			list.addAll( project.configurations.getByName( s ).files )
		}

		return list
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy