Search in sources :

Example 1 with CreateDependencyInfoFileTask

use of org.shipkit.internal.gradle.java.tasks.CreateDependencyInfoFileTask in project shipkit by mockito.

the class ComparePublicationsPlugin method apply.

@Override
public void apply(final Project project) {
    project.getPlugins().apply(JavaPublishPlugin.class);
    final ShipkitConfiguration conf = project.getPlugins().apply(ShipkitConfigurationPlugin.class).getConfiguration();
    final Jar sourcesJar = (Jar) project.getTasks().getByName(JavaLibraryPlugin.SOURCES_JAR_TASK);
    String basePreviousVersionArtifactPath = getBasePreviousVersionArtifactPath(project, conf, sourcesJar);
    final File previousSourcesJar = new File(basePreviousVersionArtifactPath + "-sources.jar");
    final CreateDependencyInfoFileTask dependencyInfoTask = TaskMaker.task(project, "createDependencyInfoFile", CreateDependencyInfoFileTask.class, new Action<CreateDependencyInfoFileTask>() {

        @Override
        public void execute(final CreateDependencyInfoFileTask task) {
            task.setDescription("Creates a file with all declared runtime dependencies.");
            task.setOutputFile(new File(project.getBuildDir(), DEPENDENCY_INFO_FILENAME));
            task.setConfiguration(project.getConfigurations().getByName("runtimeClasspath"));
            task.setProjectVersion(project.getVersion().toString());
            DeferredConfiguration.deferredConfiguration(project, new Runnable() {

                @Override
                public void run() {
                    task.setProjectGroup(project.getGroup().toString());
                }
            });
        }
    });
    sourcesJar.getMetaInf().from(dependencyInfoTask.getOutputFile());
    sourcesJar.dependsOn(dependencyInfoTask);
    TaskMaker.task(project, DOWNLOAD_PUBLICATIONS_TASK, DownloadPreviousPublicationsTask.class, new Action<DownloadPreviousPublicationsTask>() {

        @Override
        public void execute(final DownloadPreviousPublicationsTask t) {
            t.setDescription("Downloads artifacts of last released version and stores it locally for comparison");
            DeferredConfiguration.deferredConfiguration(project, new Runnable() {

                @Override
                public void run() {
                    DefaultArtifactUrlResolver artifactUrlResolver = new DefaultArtifactUrlResolverFactory().getDefaultResolver(project, sourcesJar.getBaseName(), conf.getPreviousReleaseVersion());
                    String previousVersionSourcesJarUrl = getDefaultIfNull(t.getPreviousSourcesJarUrl(), "previousSourcesJarUrl", "-sources.jar", artifactUrlResolver);
                    t.setPreviousSourcesJarUrl(previousVersionSourcesJarUrl);
                    t.setPreviousSourcesJarFile(previousSourcesJar);
                }
            });
        }
    });
    TaskMaker.task(project, COMPARE_PUBLICATIONS_TASK, ComparePublicationsTask.class, new Action<ComparePublicationsTask>() {

        public void execute(final ComparePublicationsTask t) {
            t.setDescription("Compares artifacts and poms between last version and the currently built one to see if there are any differences");
            t.dependsOn(DOWNLOAD_PUBLICATIONS_TASK);
            t.setComparisonResult(new File(project.getBuildDir(), "publications-comparison.txt"));
            t.setPreviousSourcesJar(previousSourcesJar);
            // Set local sources jar for comparison with previously released
            t.compareSourcesJar(sourcesJar);
        }
    });
}
Also used : CreateDependencyInfoFileTask(org.shipkit.internal.gradle.java.tasks.CreateDependencyInfoFileTask) ShipkitConfiguration(org.shipkit.gradle.configuration.ShipkitConfiguration) ShipkitConfigurationPlugin(org.shipkit.internal.gradle.configuration.ShipkitConfigurationPlugin) DownloadPreviousPublicationsTask(org.shipkit.gradle.java.DownloadPreviousPublicationsTask) ComparePublicationsTask(org.shipkit.gradle.java.ComparePublicationsTask) DefaultArtifactUrlResolverFactory(org.shipkit.internal.comparison.artifact.DefaultArtifactUrlResolverFactory) Jar(org.gradle.api.tasks.bundling.Jar) DefaultArtifactUrlResolver(org.shipkit.internal.comparison.artifact.DefaultArtifactUrlResolver) File(java.io.File)

Aggregations

File (java.io.File)1 Jar (org.gradle.api.tasks.bundling.Jar)1 ShipkitConfiguration (org.shipkit.gradle.configuration.ShipkitConfiguration)1 ComparePublicationsTask (org.shipkit.gradle.java.ComparePublicationsTask)1 DownloadPreviousPublicationsTask (org.shipkit.gradle.java.DownloadPreviousPublicationsTask)1 DefaultArtifactUrlResolver (org.shipkit.internal.comparison.artifact.DefaultArtifactUrlResolver)1 DefaultArtifactUrlResolverFactory (org.shipkit.internal.comparison.artifact.DefaultArtifactUrlResolverFactory)1 ShipkitConfigurationPlugin (org.shipkit.internal.gradle.configuration.ShipkitConfigurationPlugin)1 CreateDependencyInfoFileTask (org.shipkit.internal.gradle.java.tasks.CreateDependencyInfoFileTask)1