Search in sources :

Example 1 with InitShipkitFileTask

use of org.shipkit.gradle.init.InitShipkitFileTask in project shipkit by mockito.

the class InitPlugin method apply.

@Override
public void apply(final Project project) {
    project.getPlugins().apply(VersioningPlugin.class);
    project.getPlugins().apply(ShipkitConfigurationPlugin.class);
    final GitOriginPlugin gitOriginPlugin = project.getRootProject().getPlugins().apply(GitOriginPlugin.class);
    TaskMaker.task(project, INIT_TRAVIS_TASK, InitTravisTask.class, new Action<InitTravisTask>() {

        public void execute(InitTravisTask t) {
            t.setDescription("Creates '.travis.yml' file if not already present.");
            t.setOutputFile(new File(project.getRootDir(), ".travis.yml"));
        }
    });
    final BumpVersionFileTask bump = (BumpVersionFileTask) project.getTasks().getByName(VersioningPlugin.BUMP_VERSION_FILE_TASK);
    TaskMaker.task(project, INIT_VERSIONING_TASK, InitVersioningTask.class, new Action<InitVersioningTask>() {

        @Override
        public void execute(InitVersioningTask t) {
            t.setDescription("Creates version.properties file if it doesn't exist");
            t.setVersionFile(bump.getVersionFile());
        }
    });
    TaskMaker.task(project, INIT_SHIPKIT_FILE_TASK, InitShipkitFileTask.class, new Action<InitShipkitFileTask>() {

        @Override
        public void execute(final InitShipkitFileTask t) {
            final File shipkitFile = ShipkitConfigurationPlugin.getShipkitFile(project);
            t.setDescription("Creates Shipkit configuration file unless it already exists");
            t.setShipkitFile(shipkitFile);
            gitOriginPlugin.provideOriginRepo(t, new Action<String>() {

                public void execute(String originRepo) {
                    t.setOriginRepoName(originRepo);
                }
            });
        }
    });
    TaskMaker.task(project, INIT_SHIPKIT_TASK, new Action<Task>() {

        public void execute(Task t) {
            t.setDescription("Initializes Shipkit");
            t.dependsOn(INIT_TRAVIS_TASK, INIT_VERSIONING_TASK, INIT_SHIPKIT_FILE_TASK);
            t.doLast(new Action<Task>() {

                @Override
                public void execute(Task task) {
                    LOG.lifecycle("  Initialization complete. Thank you for using Shipkit!\n" + "  Please review generated files before checking them in.\n" + "  Guide: https://github.com/mockito/shipkit/blob/master/docs/getting-started.md");
                }
            });
        }
    });
    // The user might configure the 'group' later, after the plugin is applied
    DeferredConfiguration.deferredConfiguration(project, new Runnable() {

        @Override
        public void run() {
            if (project.getGroup() == null) {
                LOG.info("  Gradle project does not have 'group' property configured yet." + "\n  Shipkit is setting the group to 'org.shipkit.bootstrap' so that it has a reasonable default." + "\n  It is recommended that you configure the 'group' to your choice.");
                project.setGroup("org.shipkit.bootstrap");
            }
        }
    });
}
Also used : Action(org.gradle.api.Action) InitTravisTask(org.shipkit.gradle.init.InitTravisTask) Task(org.gradle.api.Task) InitVersioningTask(org.shipkit.gradle.init.InitVersioningTask) InitShipkitFileTask(org.shipkit.gradle.init.InitShipkitFileTask) BumpVersionFileTask(org.shipkit.gradle.version.BumpVersionFileTask) InitTravisTask(org.shipkit.gradle.init.InitTravisTask) BumpVersionFileTask(org.shipkit.gradle.version.BumpVersionFileTask) GitOriginPlugin(org.shipkit.internal.gradle.git.GitOriginPlugin) InitShipkitFileTask(org.shipkit.gradle.init.InitShipkitFileTask) InitVersioningTask(org.shipkit.gradle.init.InitVersioningTask) File(java.io.File)

Aggregations

File (java.io.File)1 Action (org.gradle.api.Action)1 Task (org.gradle.api.Task)1 InitShipkitFileTask (org.shipkit.gradle.init.InitShipkitFileTask)1 InitTravisTask (org.shipkit.gradle.init.InitTravisTask)1 InitVersioningTask (org.shipkit.gradle.init.InitVersioningTask)1 BumpVersionFileTask (org.shipkit.gradle.version.BumpVersionFileTask)1 GitOriginPlugin (org.shipkit.internal.gradle.git.GitOriginPlugin)1