use of org.gradle.api.GradleException in project gradle by gradle.
the class DefaultHttpBuildCacheServiceFactory method createBuildCacheService.
@Override
public BuildCacheService createBuildCacheService(HttpBuildCache configuration) {
URI url = configuration.getUrl();
if (url == null) {
throw new IllegalStateException("HTTP build cache has no URL configured");
}
Collection<Authentication> authentications = Collections.emptyList();
if (configuration.getCredentials().getUsername() != null && configuration.getCredentials().getPassword() != null) {
try {
url = new URI(url.getScheme(), null, url.getHost(), url.getPort(), url.getPath(), url.getQuery(), url.getFragment());
} catch (URISyntaxException e) {
throw new GradleException("Error constructing URL for http build cache", e);
}
DefaultBasicAuthentication basicAuthentication = new DefaultBasicAuthentication("basic");
basicAuthentication.setCredentials(configuration.getCredentials());
authentications = Collections.<Authentication>singleton(basicAuthentication);
}
HttpClientHelper httpClientHelper = new HttpClientHelper(new DefaultHttpSettings(authentications, sslContextFactory));
return new HttpBuildCacheService(httpClientHelper, url);
}
use of org.gradle.api.GradleException in project gradle by gradle.
the class CompareGradleBuilds method communicateResult.
private void communicateResult(BuildComparisonResult result) {
File reportFile = new File(getReportDir(), GradleBuildComparison.HTML_REPORT_FILE_NAME);
String reportUrl = new ConsoleRenderer().asClickableFileUrl(reportFile);
if (result.isBuildsAreIdentical()) {
getLogger().info("The build outcomes were found to be identical. See the report at: {}", reportUrl);
} else {
String message = String.format("The build outcomes were not found to be identical. See the report at: %s", reportUrl);
if (getIgnoreFailures()) {
getLogger().warn(message);
} else {
throw new GradleException(message);
}
}
}
use of org.gradle.api.GradleException in project gradle by gradle.
the class FindBugs method evaluateResult.
@VisibleForTesting
void evaluateResult(FindBugsResult result) {
if (result.getException() != null) {
throw new GradleException("FindBugs encountered an error. Run with --debug to get more information.", result.getException());
}
if (result.getErrorCount() > 0) {
throw new GradleException("FindBugs encountered an error. Run with --debug to get more information.");
}
if (result.getBugCount() > 0) {
String message = "FindBugs rule violations were found.";
SingleFileReport report = reports.getFirstEnabled();
if (report != null) {
String reportUrl = new ConsoleRenderer().asClickableFileUrl(report.getDestination());
message += " See the report at: " + reportUrl;
}
if (getIgnoreFailures()) {
getLogger().warn(message);
} else {
throw new GradleException(message);
}
}
}
use of org.gradle.api.GradleException in project atlas by alibaba.
the class AtlasLibTaskManager method runTask.
@Override
public void runTask() {
//不做资源的合并
if (!atlasExtension.getBundleConfig().isMergeRes()) {
new ResMerger(project).mergeRes();
}
//对maven发布失败做异常翻译, 一目了然
new PublishHooker(project).hookPublish();
libraryExtension.getLibraryVariants().forEach(new Consumer<LibraryVariant>() {
@Override
public void accept(LibraryVariant libraryVariant) {
//if ("debug".equals(libraryVariant.getBaseName())) {
// new ModuleInfoWriter(project,libraryVariant).write();
//}
LibVariantContext libVariantContext = new LibVariantContext((LibraryVariantImpl) libraryVariant, project, atlasExtension, libraryExtension);
List<Zip> zipTasks = libVariantContext.getZipTasks();
if (zipTasks.isEmpty()) {
return;
}
for (Zip zipTask : zipTasks) {
new AndroidComponetCreator(atlasExtension, project).createAndroidComponent(zipTask);
//生成 awb 和 jar
new AwbGenerator(atlasExtension).generate(zipTask);
}
}
});
libraryExtension.getLibraryVariants().forEach(new Consumer<LibraryVariant>() {
@Override
public void accept(LibraryVariant libraryVariant) {
LibVariantContext libVariantContext = new LibVariantContext((LibraryVariantImpl) libraryVariant, project, atlasExtension, libraryExtension);
List<Zip> zipTasks = libVariantContext.getZipTasks();
if (zipTasks.isEmpty()) {
return;
}
for (Zip zipTask : zipTasks) {
TBuildType tBuildType = libVariantContext.getBuildType();
if (null != tBuildType) {
try {
new AwoPropHandler().process(tBuildType, atlasExtension.getBundleConfig());
} catch (Exception e) {
throw new GradleException("process awo exception", e);
}
}
//TODO DEBUG it
if (atlasExtension.getBundleConfig().isAwoBuildEnabled() && libraryVariant.getName().equals("debug")) {
libVariantContext.setBundleTask(zipTask);
try {
libVariantContext.setAwbBundle(createAwbBundle(libVariantContext, libraryVariant.getName()));
} catch (IOException e) {
throw new GradleException("set awb bundle error");
}
if (atlasExtension.getBundleConfig().isAwbBundle()) {
createAwoTask(libVariantContext, zipTask);
} else {
createDexTask(libVariantContext, zipTask);
}
}
}
}
});
}
use of org.gradle.api.GradleException in project atlas by alibaba.
the class PrepareMainDexJarsTask method doFullTaskAction.
@TaskAction
public void doFullTaskAction() {
AndroidDependencyTree libDependencyTree = AtlasBuildContext.libDependencyTrees.get(this.getVariantName());
if (null == libDependencyTree) {
throw new GradleException("The libDependencyTree is null!");
}
List<File> jarList = new AwoDependency(libVariantContext).getDependencyJar(libDependencyTree);
libVariantContext.setJarDexList(jarList);
}
Aggregations