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

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

package flair.gradle.tasks.process

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 ProcessIcons 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 }/package/icons" )
	}

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

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

		for( File file : inputFiles )
		{
			if( file.exists( ) && project.fileTree( file.path ).size( ) > 0 )
			{
				project.copy {
					from file
					into outputDir

					include "*.png"
				}

				break
			}
		}
	}

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

		variant.directories.each { list.add( project.file( "${ moduleDir }/src/${ it }/icons" ) ) }

		return list.reverse( )
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy