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

org.xtext.gradle.idea.IdeaPluginPlugin.xtend Maven / Gradle / Ivy

There is a newer version: 2.0.9-alpha.3
Show newest version
package org.xtext.gradle.idea

import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.plugins.JavaPlugin
import org.gradle.api.plugins.JavaPluginConvention
import org.gradle.api.tasks.bundling.Zip
import org.xtext.gradle.idea.tasks.AssembleSandbox
import org.gradle.api.plugins.BasePlugin

class IdeaPluginPlugin implements Plugin {
	public static val IDEA_ZIP_TASK_NAME = "ideaZip"

	override apply(Project project) {
		project.plugins.apply(IdeaComponentPlugin)
		val java = project.convention.getPlugin(JavaPluginConvention)
		val mainSourceSet = java.sourceSets.getByName("main")
		val providedDependencies = project.configurations.getAt(IdeaComponentPlugin.IDEA_PROVIDED_CONFIGURATION_NAME)
		val runtimeDependencies = project.configurations.getAt(JavaPlugin.RUNTIME_CONFIGURATION_NAME)
		val assembleSandbox = project.tasks.getAt(IdeaComponentPlugin.ASSEMBLE_SANDBOX_TASK_NAME) as AssembleSandbox
		
		assembleSandbox => [
			classes.from(mainSourceSet.output)
			libraries.from(runtimeDependencies.filter [ candidate |
				!providedDependencies.exists[candidate.name == name]
			])
			metaInf.from("META-INF")
		]

		val ideaZip = project.tasks.create(IDEA_ZIP_TASK_NAME, Zip) [
			description = "Creates an installable archive of this plugin"
			group = BasePlugin.BUILD_GROUP
			with(assembleSandbox.plugin)
		]
		project.tasks.getAt(BasePlugin.ASSEMBLE_TASK_NAME).dependsOn(ideaZip)
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy