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

flair.gradle.tasks.process.ProcessAsLibraries.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 ProcessAsLibraries 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 }/asLibraries" )
	}

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

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

		inputFiles.each { file ->

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

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

		variant.directoriesCapitalized.each {

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

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

		return list
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy