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

org.dm.gradle.plugins.bundle.BundlePlugin.groovy Maven / Gradle / Ivy

There is a newer version: 0.10.0
Show newest version
package org.dm.gradle.plugins.bundle

import org.gradle.api.GradleException
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.plugins.JavaBasePlugin
import org.gradle.api.plugins.JavaPlugin
import org.gradle.api.plugins.osgi.OsgiPlugin

/**
 * A bundle plugin which internally uses
 * the bnd tool
 * for generating bundles.
 */
class BundlePlugin implements Plugin {
    /**
     * {@inheritDoc}
     */
    @Override
    public void apply(Project project) {
        project.extensions.create("bundle", BundleExtension)

        project.plugins.apply(JavaBasePlugin)
        project.plugins.withType(OsgiPlugin) {
            throw new GradleException("gradle-bundle-plugin is not compatible with osgi plugin")
        }
        project.plugins.withType(JavaPlugin) {
            project.jar { jarTask ->
                def jarBuilderFactory = new JarBuilderFactoryDecorator(
                        jarTask, project.bundle.jarBuilderFactory)

                deleteAllActions()
                doLast(new BundleGenerator(jarBuilderFactory))
                manifest = new ManifestSubstitute(jarBuilderFactory, manifest)
            }
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy