de.undercouch.gradle.tasks.download.VerifyExtension Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gradle-download-task Show documentation
Show all versions of gradle-download-task Show documentation
Adds a download task to Gradle that displays progress information
The newest version!
package de.undercouch.gradle.tasks.download;
import org.gradle.api.Action;
import org.gradle.api.Project;
import org.gradle.api.Task;
import org.gradle.api.file.ProjectLayout;
import javax.inject.Inject;
import java.io.IOException;
import java.security.NoSuchAlgorithmException;
/**
* An extension that executes a {@link VerifyAction}
* @author Michel Kraemer
*/
public class VerifyExtension {
private final ProjectLayout projectLayout;
/**
* Creates a new extension
* @param project the project to be built
*/
public VerifyExtension(Project project) {
this.projectLayout = project.getLayout();
}
/**
* Creates a new extension
* @param task the current task
*/
@Inject
public VerifyExtension(Task task) {
this(task.getProject());
}
public void run(Action action) {
VerifyAction va = new VerifyAction(projectLayout);
action.execute(va);
try {
va.execute();
} catch (IOException | NoSuchAlgorithmException e) {
throw new IllegalStateException("Could not verify file checksum", e);
}
}
}