Java Code Examples for org.gradle.api.project#task()
The following examples show how to use
org.gradle.api.project#task() .
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: OssIndexPlugin.java From ossindex-gradle-plugin with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public synchronized void apply(Project project) { logger.info("Apply OSS Index Plugin"); this.project = project; project.getExtensions().create("audit", AuditExtensions.class, project); Task audit = project.task("audit"); Proxy proxy = getProxy(project, "http"); if (proxy != null) { proxies.add(proxy); }proxy = getProxy(project, "https"); if (proxy != null) { proxies.add(proxy); } audit.doLast(this::doAudit); }
Example 2
Source File: JavaBasePlugin.java From javaide with GNU General Public License v3.0 | 5 votes |
private void createBinaryLifecycleTask(SourceSet sourceSet, Project target) { sourceSet.compiledBy(sourceSet.getClassesTaskName()); Task binaryLifecycleTask = target.task(sourceSet.getClassesTaskName()); binaryLifecycleTask.setGroup(LifecycleBasePlugin.BUILD_GROUP); binaryLifecycleTask.setDescription("Assembles " + sourceSet.getOutput() + "."); binaryLifecycleTask.dependsOn(sourceSet.getOutput().getDirs()); binaryLifecycleTask.dependsOn(sourceSet.getCompileJavaTaskName()); binaryLifecycleTask.dependsOn(sourceSet.getProcessResourcesTaskName()); }
Example 3
Source File: MeecrowavePlugin.java From openwebbeans-meecrowave with Apache License 2.0 | 5 votes |
@Override public void apply(final Project project) { project.getExtensions().create(NAME, MeecrowaveExtension.class); project.afterEvaluate(actionProject -> { final MeecrowaveExtension extension = MeecrowaveExtension.class.cast(actionProject.getExtensions().findByName(NAME)); if (extension != null && extension.isSkipMavenCentral()) { return; } actionProject.getRepositories().mavenCentral(); }); final Configuration configuration = project.getConfigurations().maybeCreate(NAME); configuration.getIncoming().beforeResolve(resolvableDependencies -> { String version; try { final String resource = "META-INF/maven/org.apache.meecrowave/meecrowave-gradle-plugin/pom.properties"; try (final InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(resource)) { final Properties p = new Properties(); p.load(is); version = p.getProperty("version"); } } catch (final IOException e) { throw new IllegalStateException(e); } final DependencyHandler dependencyHandler = project.getDependencies(); final DependencySet dependencies = configuration.getDependencies(); dependencies.add(dependencyHandler.create("org.apache.meecrowave:meecrowave-core:" + version)); }); project.task(new HashMap<String, Object>() {{ put("type", MeecrowaveTask.class); put("group", "Embedded Application Server"); put("description", "Starts a meecrowave!"); }}, NAME); }
Example 4
Source File: DeployTaskTest.java From gradle-beanstalk-plugin with MIT License | 5 votes |
@Test public void versionShouldIncludePrefix() { Project project = ProjectBuilder.builder().build(); project.setVersion("version"); Map<String, Object> params = new HashMap<>(); params.put("type", TestDeployTask.class); TestDeployTask task = (TestDeployTask) project.task(params, "tasktest"); BeanstalkDeployment deployment = new BeanstalkDeployment("tasktest"); deployment.setVersionPrefix("test-"); task.setDeployment(deployment); assertTrue(task.findVersionLabel().matches("test-version")); }
Example 5
Source File: JavaccPlugin.java From javaccPlugin with MIT License | 5 votes |
private void addTaskToProject(Project project, Class<? extends AbstractJavaccTask> type, String name, String description, String group, Configuration configuration) { Map<String, Object> options = new HashMap<String, Object>(3); options.put(Task.TASK_TYPE, type); options.put(Task.TASK_DESCRIPTION, description); options.put(Task.TASK_GROUP, group); AbstractJavaccTask task = (AbstractJavaccTask) project.task(options, name); task.getConventionMapping().map("classpath", Callables.returning(configuration)); }
Example 6
Source File: JavaccCompilerInputOutputConfigurationTest.java From javaccPlugin with MIT License | 5 votes |
private File addTaskWithSourceFile(Project project, String taskName, String sourceFileName, Class<? extends SourceTask> taskType) throws IOException { Map<String, Object> options = new HashMap<String, Object>(); options.put(Task.TASK_TYPE, taskType); SourceTask compileJava = (SourceTask) project.task(options, taskName); File javaFile = testFolder.newFile(sourceFileName); compileJava.source(javaFile.getCanonicalFile()); return javaFile; }
Example 7
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 8
Source File: SmokeTestsPlugin.java From firebase-android-sdk with Apache License 2.0 | 4 votes |
@Override public void apply(Project project) { Task assembleAllTask = project.task("assembleAllForSmokeTests"); // Wait until after the projects have been evaluated or else we might skip projects. project .getGradle() .projectsEvaluated( gradle -> { Set<Project> changedProjects = getChangedProjects(project); Set<String> changedArtifacts = new HashSet<>(); Set<String> allArtifacts = new HashSet<>(); // Visit each project and add the artifacts to the appropriate sets. project.subprojects( sub -> { FirebaseLibraryExtension firebaseLibrary = sub.getExtensions().findByType(FirebaseLibraryExtension.class); if (firebaseLibrary == null) { return; } String groupId = firebaseLibrary.groupId.get(); String artifactId = firebaseLibrary.artifactId.get(); String artifact = String.format("%s:%s:%s-SNAPSHOT", groupId, artifactId, sub.getVersion()); allArtifacts.add(artifact); if (changedProjects.contains(sub)) { changedArtifacts.add(artifact); } }); // Reuse the publish task for building the libraries. Task publishAllTask = project.getTasks().getByPath("publishAllToBuildDir"); assembleAllTask.dependsOn(publishAllTask); // Generate a JSON file listing the artifacts after everything is complete. assembleAllTask.doLast( task -> { JSONArray changed = new JSONArray(); changedArtifacts.forEach(changed::put); JSONArray all = new JSONArray(); allArtifacts.forEach(all::put); JSONObject json = new JSONObject(); json.put("headGit", all); json.put("default", changed); Path path = project.getBuildDir().toPath(); Path jsonFile = path.resolve( "m2repository/changed-artifacts.json"); // .write(json.toString()) try { Files.write( jsonFile, Collections.singleton(json.toString()), Charset.defaultCharset()); } catch (IOException e) { throw new GradleException("Failed to write '" + jsonFile + "' json file.", e); } }); }); }