本文整理匯總了Java中org.gradle.api.GradleException類的典型用法代碼示例。如果您正苦於以下問題:Java GradleException類的具體用法?Java GradleException怎麽用?Java GradleException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
GradleException類屬於org.gradle.api包,在下文中一共展示了GradleException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: publishArtifacts
import org.gradle.api.GradleException; //導入依賴的package包/類
@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);
}
示例2: getClasspathForClass
import org.gradle.api.GradleException; //導入依賴的package包/類
public static File getClasspathForClass(Class<?> targetClass) {
URI location;
try {
CodeSource codeSource = targetClass.getProtectionDomain().getCodeSource();
if (codeSource != null && codeSource.getLocation() != null) {
location = codeSource.getLocation().toURI();
if (location.getScheme().equals("file")) {
return new File(location);
}
}
if (targetClass.getClassLoader() != null) {
String resourceName = targetClass.getName().replace('.', '/') + ".class";
URL resource = targetClass.getClassLoader().getResource(resourceName);
if (resource != null) {
return getClasspathForResource(resource, resourceName);
}
}
throw new GradleException(String.format("Cannot determine classpath for class %s.", targetClass.getName()));
} catch (URISyntaxException e) {
throw UncheckedException.throwAsUncheckedException(e);
}
}
示例3: execute
import org.gradle.api.GradleException; //導入依賴的package包/類
@Override
public WorkResult execute(JavadocSpec spec) {
JavadocExecHandleBuilder javadocExecHandleBuilder = new JavadocExecHandleBuilder(execActionFactory);
javadocExecHandleBuilder.setExecutable(spec.getExecutable());
javadocExecHandleBuilder.execDirectory(spec.getWorkingDir()).options(spec.getOptions()).optionsFile(spec.getOptionsFile());
ExecAction execAction = javadocExecHandleBuilder.getExecHandle();
if (spec.isIgnoreFailures()) {
execAction.setIgnoreExitValue(true);
}
try {
execAction.execute();
} catch (ExecException e) {
LOG.info("Problems generating Javadoc."
+ "\n Command line issued: " + execAction.getCommandLine()
+ "\n Generated Javadoc options file has following contents:\n------\n{}------", GFileUtils.readFileQuietly(spec.getOptionsFile()));
throw new GradleException(String.format("Javadoc generation failed. Generated Javadoc options file (useful for troubleshooting): '%s'", spec.getOptionsFile()), e);
}
return new SimpleWorkResult(true);
}
示例4: getExecHandle
import org.gradle.api.GradleException; //導入依賴的package包/類
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;
}
示例5: execute
import org.gradle.api.GradleException; //導入依賴的package包/類
@Override
public void execute(Task task) {
Set<? extends Task> taskDependencies = task.getTaskDependencies().getDependencies(task);
if (taskDependencies.isEmpty()) {
TreeFormatter formatter = new TreeFormatter();
formatter.node("No buildable binaries found");
formatter.startChildren();
for (BinarySpecInternal binary : notBuildable) {
formatter.node(binary.getDisplayName());
formatter.startChildren();
binary.getBuildAbility().explain(formatter);
formatter.endChildren();
}
formatter.endChildren();
throw new GradleException(formatter.toString());
}
}
示例6: doRunWithFailure
import org.gradle.api.GradleException; //導入依賴的package包/類
@Override
protected ExecutionFailure doRunWithFailure() {
if (isForkRequired()) {
return doStart().waitForFailure();
}
StandardOutputListener outputListener = new OutputListenerImpl();
StandardOutputListener errorListener = new OutputListenerImpl();
BuildListenerImpl buildListener = new BuildListenerImpl();
try {
doRun(outputListener, errorListener, buildListener).rethrowFailure();
throw new AssertionError("expected build to fail but it did not.");
} catch (GradleException e) {
return assertResult(new InProcessExecutionFailure(buildListener.executedTasks, buildListener.skippedTasks,
new OutputScrapingExecutionFailure(outputListener.toString(), errorListener.toString()), e));
}
}
示例7: setupProjectLayout
import org.gradle.api.GradleException; //導入依賴的package包/類
@TaskAction
public void setupProjectLayout() {
final String type = getType();
BuildInitTestFramework testFramework = BuildInitTestFramework.fromName(getTestFramework());
final ProjectLayoutSetupRegistry projectLayoutRegistry = getProjectLayoutRegistry();
if (!projectLayoutRegistry.supports(type)) {
String supportedTypes = Joiner.on(", ").join(Iterables.transform(projectLayoutRegistry.getSupportedTypes(), new Function<String, String>() {
@Override
public String apply(String input) {
return "'" + input + "'";
}
}));
throw new GradleException("The requested build setup type '" + type + "' is not supported. Supported types: " + supportedTypes + ".");
}
ProjectInitDescriptor initDescriptor = projectLayoutRegistry.get(type);
if (!testFramework.equals(BuildInitTestFramework.NONE) && !initDescriptor.supports(testFramework)) {
throw new GradleException("The requested test framework '" + testFramework.getId() + "' is not supported in '" + type + "' setup type");
}
initDescriptor.generate(testFramework);
}
示例8: runAudit
import org.gradle.api.GradleException; //導入依賴的package包/類
public Collection<MavenPackageDescriptor> runAudit() {
try {
List<MavenPackageDescriptor> results = new LinkedList<>();
Collection<PackageDescriptor> packages = request.run();
for (PackageDescriptor pkg : packages) {
MavenPackageDescriptor mvnPkg = new MavenPackageDescriptor(pkg);
if (parents.containsKey(pkg)) {
PackageDescriptor parent = parents.get(pkg);
if (parent != null) {
mvnPkg.setParent(new MavenIdWrapper(parent));
}
}
if (mvnPkg.getVulnerabilityMatches() > 0) {
results.add(mvnPkg);
}
}
return results;
}
catch(IOException e) {
throw new GradleException("Error trying to get audit results", e);
}
}
示例9: generate
import org.gradle.api.GradleException; //導入依賴的package包/類
/**
* Generate this file
*/
@TaskAction
public void generate() throws IOException {
dependencyDiff = getDependencyDiff();
//If it's patch, get the diff operation
if (null == dependencyDiff) {
return;
}
try {
appVariantOutputContext.artifactBundleInfos = getArtifactBundleInfo(getDependencyDiff(),
getManifestFile(),
getApDir());
FileUtils.writeStringToFile(new File(getOutJsonFile(), "dependencyDiff.json"),
JSON.toJSONString(dependencyDiff, true));
} catch (Exception e) {
throw new GradleException(e.getMessage());
}
}
示例10: resolveToFoundResult
import org.gradle.api.GradleException; //導入依賴的package包/類
private Result resolveToFoundResult(PluginResolver effectivePluginResolver, PluginRequest request) {
Result result = new Result(request);
try {
effectivePluginResolver.resolve(request, result);
} catch (Exception e) {
throw new LocationAwareException(
new GradleException(String.format("Error resolving plugin %s", request.getDisplayName()), e),
request.getScriptDisplayName(), request.getLineNumber());
}
if (!result.isFound()) {
String message = buildNotFoundMessage(request, result);
Exception exception = new UnknownPluginException(message);
throw new LocationAwareException(exception, request.getScriptDisplayName(), request.getLineNumber());
}
return result;
}
示例11: parseJavaVersionCommandOutput
import org.gradle.api.GradleException; //導入依賴的package包/類
private JavaVersion parseJavaVersionCommandOutput(String javaExecutable, BufferedReader reader) {
try {
String versionStr = reader.readLine();
while (versionStr != null) {
Matcher matcher = Pattern.compile("(?:java|openjdk) version \"(.+?)\"").matcher(versionStr);
if (matcher.matches()) {
return JavaVersion.toVersion(matcher.group(1));
}
versionStr = reader.readLine();
}
} catch (IOException e) {
throw new UncheckedIOException(e);
}
throw new GradleException(String.format("Could not determine Java version using executable %s.", javaExecutable));
}
示例12: executeSQLExecutor
import org.gradle.api.GradleException; //導入依賴的package包/類
@TaskAction
public void executeSQLExecutor() {
String taskName = this.getName();
if (sqlFiles==null) {
throw new GradleException("sqlFiles is null");
}
List<File> files = convertToFileList(sqlFiles);
try {
SqlExecutorStep step = new SqlExecutorStep(taskName);
step.execute(database, files,sqlParameters);
log.info("Task start");
} catch (Exception e) {
log.error("Exception in creating / invoking SqlExecutorStep.", e);
GradleException ge = TaskUtil.toGradleException(e);
throw ge;
}
}
示例13: setLaunchables
import org.gradle.api.GradleException; //導入依賴的package包/類
public Builder setLaunchables(Iterable<? extends Launchable> launchables) {
Set<String> taskPaths = new LinkedHashSet<String>();
List<InternalLaunchable> launchablesParams = Lists.newArrayList();
for (Launchable launchable : launchables) {
Object original = new ProtocolToModelAdapter().unpack(launchable);
if (original instanceof InternalLaunchable) {
// A launchable created by the provider - just hand it back
launchablesParams.add((InternalLaunchable) original);
} else if (original instanceof TaskListingLaunchable) {
// A launchable synthesized by the consumer - unpack it into a set of task names
taskPaths.addAll(((TaskListingLaunchable) original).getTaskNames());
} else if (launchable instanceof Task) {
// A task created by a provider that does not understand launchables
taskPaths.add(((Task) launchable).getPath());
} else {
throw new GradleException("Only Task or TaskSelector instances are supported: "
+ (launchable != null ? launchable.getClass() : "null"));
}
}
// Tasks are ignored by providers if launchables is not null
this.launchables = launchablesParams.isEmpty() ? null : launchablesParams;
tasks = Lists.newArrayList(taskPaths);
return this;
}
示例14: getClassObfMap
import org.gradle.api.GradleException; //導入依賴的package包/類
private Map<String, String> getClassObfMap(GradleVariantConfiguration config) {
Map<String, String> classMap = new HashMap<String, String>();
boolean isMinifyEnabled = config.isMinifyEnabled();
File proguardOut = new File(Joiner.on(File.separatorChar).join(
String.valueOf(appVariantContext.getScope().getGlobalScope().getBuildDir()), FD_OUTPUTS, "mapping",
appVariantContext.getScope().getVariantConfiguration().getDirName()));
File mappingFile = new File(proguardOut, "mapping.txt");
// Parse the mapping file to generate the new mainDexListFile
if (isMinifyEnabled && mappingFile.exists()) {
MappingReader mappingReader = new MappingReader(mappingFile);
MappingReaderProcess process = new MappingReaderProcess();
try {
mappingReader.pump(process);
} catch (IOException e) {
throw new GradleException(e.getMessage(), e);
}
classMap = process.classMapping;
}
return classMap;
}
示例15: generate
import org.gradle.api.GradleException; //導入依賴的package包/類
@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());
}