use of org.gradle.api.GradleException in project gradle by gradle.
the class JavadocExecHandleBuilder method getExecHandle.
public ExecAction getExecHandle() {
try {
options.write(optionsFile);
} catch (IOException e) {
throw new GradleException("Failed to store javadoc options.", e);
}
ExecAction execAction = execActionFactory.newExecAction();
execAction.workingDir(execDirectory);
execAction.executable(GUtil.elvis(executable, Jvm.current().getJavadocExecutable()));
execAction.args("@" + optionsFile.getAbsolutePath());
options.contributeCommandLineOptions(execAction);
return execAction;
}
use of org.gradle.api.GradleException in project gradle by gradle.
the class ClasspathUtil method getClasspathForResource.
public static File getClasspathForResource(URL resource, String name) {
URI location;
try {
location = toURI(resource);
String path = location.getPath();
if (location.getScheme().equals("file")) {
assert path.endsWith("/" + name);
return new File(path.substring(0, path.length() - (name.length() + 1)));
} else if (location.getScheme().equals("jar")) {
String schemeSpecificPart = location.getRawSchemeSpecificPart();
int pos = schemeSpecificPart.indexOf("!");
if (pos > 0) {
assert schemeSpecificPart.substring(pos + 1).equals("/" + name);
URI jarFile = new URI(schemeSpecificPart.substring(0, pos));
if (jarFile.getScheme().equals("file")) {
return new File(jarFile.getPath());
}
}
}
} catch (URISyntaxException e) {
throw UncheckedException.throwAsUncheckedException(e);
}
throw new GradleException(String.format("Cannot determine classpath for resource '%s' from location '%s'.", name, location));
}
use of org.gradle.api.GradleException in project gradle by gradle.
the class CachingTaskDependencyResolveContext method resolve.
public Set<Task> resolve(Task task) {
this.task = task;
try {
return doResolve();
} catch (Exception e) {
throw new GradleException(String.format("Could not determine the dependencies of %s.", task), e);
} finally {
queue.clear();
this.task = null;
}
}
use of org.gradle.api.GradleException in project gradle by gradle.
the class GeneratorTask method generate.
@SuppressWarnings("UnusedDeclaration")
@TaskAction
void generate() {
File inputFile = getInputFileIfExists();
if (inputFile != null) {
try {
domainObject = generator.read(inputFile);
} catch (RuntimeException e) {
throw new GradleException(String.format("Cannot parse file '%s'.\n" + " Perhaps this file was tinkered with? In that case try delete this file and then retry.", inputFile), e);
}
} else {
domainObject = generator.defaultInstance();
}
beforeConfigured.execute(domainObject);
generator.configure(domainObject);
afterConfigured.execute(domainObject);
generator.write(domainObject, getOutputFile());
}
use of org.gradle.api.GradleException in project gradle by gradle.
the class MavenDeployAction method publishArtifacts.
@Override
protected void publishArtifacts(Collection<Artifact> artifacts, RepositorySystem repositorySystem, RepositorySystemSession session) throws DeploymentException {
RemoteRepository gradleRepo = remoteRepository;
if (artifacts.iterator().next().isSnapshot() && remoteSnapshotRepository != null) {
gradleRepo = remoteSnapshotRepository;
}
if (gradleRepo == null) {
throw new GradleException("Must specify a repository for deployment");
}
org.sonatype.aether.repository.RemoteRepository aetherRepo = createRepository(gradleRepo);
DeployRequest request = new DeployRequest();
request.setRepository(aetherRepo);
for (Artifact artifact : artifacts) {
request.addArtifact(artifact);
}
LOGGER.info("Deploying to {}", gradleRepo.getUrl());
repositorySystem.deploy(session, request);
}
Aggregations