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);
}
});
}
Aggregations