Java Code Examples for org.gradle.api.project#apply()
The following examples show how to use
org.gradle.api.project#apply() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ShipkitConfigurationPlugin.java From shipkit with MIT License | 6 votes |
private static void loadConfigFromFile(final Project rootProject, File shipkitFile, ShipkitConfiguration conf) { if (!shipkitFile.exists()) { // sets some defaults so that they can't be used to run any task (except for bootstrap ones) // but also configuration doesn't fail when running Shipkit for the first time // and configuration files are not created yet conf.getGitHub().setRepository("unspecified"); conf.getGitHub().setReadOnlyAuthToken("unspecified"); LOG.lifecycle(" Configuration file '{}' does not exist. '{}' task can be used to bootstrap Shipkit.\n" + " Getting Started Guide: https://github.com/mockito/shipkit/blob/master/docs/getting-started.md", shipkitFile.getName(), InitPlugin.INIT_SHIPKIT_TASK); } else { // apply configuration properties from config file rootProject.apply(new Action<ObjectConfigurationAction>() { @Override public void execute(ObjectConfigurationAction action) { action.from(getShipkitFile(rootProject)); } }); } }
Example 2
Source File: TestBase.java From gradle-download-task with Apache License 2.0 | 5 votes |
/** * Makes a Gradle project and creates a download task * @return the unconfigured download task */ protected Download makeProjectAndTask() { Project project = ProjectBuilder.builder().withProjectDir(projectDir).build(); Map<String, Object> applyParams = new HashMap<>(); applyParams.put("plugin", "de.undercouch.download"); project.apply(applyParams); Map<String, Object> taskParams = new HashMap<>(); taskParams.put("type", Download.class); return (Download)project.task(taskParams, "downloadFile"); }
Example 3
Source File: FirebaseLibraryPlugin.java From firebase-android-sdk with Apache License 2.0 | 4 votes |
@Override public void apply(Project project) { project.apply(ImmutableMap.of("plugin", "com.android.library")); FirebaseLibraryExtension firebaseLibrary = project .getExtensions() .create( "firebaseLibrary", FirebaseLibraryExtension.class, project, LibraryType.ANDROID); LibraryExtension android = project.getExtensions().getByType(LibraryExtension.class); // In the case of and android library signing config only affects instrumentation test APK. // We need it signed with default debug credentials in order for FTL to accept the APK. android.buildTypes( types -> types .getByName("release") .setSigningConfig(types.getByName("debug").getSigningConfig())); // see https://github.com/robolectric/robolectric/issues/5456 android.testOptions( options -> options .getUnitTests() .all( closureOf( test -> { test.systemProperty("robolectric.dependency.repo.id", "central"); test.systemProperty( "robolectric.dependency.repo.url", "https://repo1.maven.org/maven2"); test.systemProperty("javax.net.ssl.trustStoreType", "JKS"); }))); // skip debug tests in CI // TODO(vkryachko): provide ability for teams to control this if needed if (System.getenv().containsKey("FIREBASE_CI")) { android.setTestBuildType("release"); project .getTasks() .all( task -> { if ("testDebugUnitTest".equals(task.getName())) { task.setEnabled(false); } }); } setupApiInformationAnalysis(project, android); android.testServer(new FirebaseTestServer(project, firebaseLibrary.testLab)); setupStaticAnalysis(project, firebaseLibrary); // reduce the likelihood of kotlin module files colliding. project .getTasks() .withType( KotlinCompile.class, kotlin -> kotlin .getKotlinOptions() .setFreeCompilerArgs( ImmutableList.of("-module-name", kotlinModuleName(project)))); project.afterEvaluate(p -> Dokka.configure(project, android, firebaseLibrary)); }
Example 4
Source File: Coverage.java From firebase-android-sdk with Apache License 2.0 | 4 votes |
public static void apply(FirebaseLibraryExtension firebaseLibrary) { Project project = firebaseLibrary.project; project.apply(ImmutableMap.of("plugin", "jacoco")); File reportsDir = new File(project.getBuildDir(), "/reports/jacoco"); JacocoPluginExtension jacoco = project.getExtensions().getByType(JacocoPluginExtension.class); jacoco.setToolVersion("0.8.5"); jacoco.setReportsDir(reportsDir); project .getTasks() .withType( Test.class, test -> { JacocoTaskExtension testJacoco = test.getExtensions().getByType(JacocoTaskExtension.class); testJacoco.setExcludeClassLoaders(ImmutableList.of("jdk.internal.*")); testJacoco.setIncludeNoLocationClasses(true); }); project .getTasks() .create( "checkCoverage", JacocoReport.class, task -> { task.dependsOn("check"); task.setDescription("Generates JaCoCo check coverage report."); task.setGroup("verification"); List<String> excludes = ImmutableList.<String>builder() .add("**/R.class") .add("**/R$*.class") .add("**/BuildConfig.*") .add("**/proto/**") .add("**Manifest*.*") .build(); task.setClassDirectories( project.files( project.fileTree( ImmutableMap.of( "dir", project.getBuildDir() + "/intermediates/javac/release", "excludes", excludes)), project.fileTree( ImmutableMap.of( "dir", project.getBuildDir() + "/tmp/kotlin-classes/release", "excludes", excludes)))); task.setSourceDirectories(project.files("src/main/java", "src/main/kotlin")); task.setExecutionData( project.fileTree( ImmutableMap.of( "dir", project.getBuildDir(), "includes", ImmutableList.of("jacoco/*.exec")))); task.reports( reports -> { reports .getHtml() .setDestination( new File(reportsDir, firebaseLibrary.artifactId.get() + "/html")); reports.getXml().setEnabled(true); reports .getXml() .setDestination( new File(reportsDir, firebaseLibrary.artifactId.get() + ".xml")); }); task.getOutputs().upToDateWhen(t -> false); }); }