org.gradle.api.Project Java Examples
The following examples show how to use
org.gradle.api.Project.
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: AbstractReportTask.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
@TaskAction public void generate() { try { ReportRenderer renderer = getRenderer(); File outputFile = getOutputFile(); if (outputFile != null) { renderer.setOutputFile(outputFile); } else { renderer.setOutput(getServices().get(StyledTextOutputFactory.class).create(getClass())); } Set<Project> projects = new TreeSet<Project>(getProjects()); for (Project project : projects) { renderer.startProject(project); generate(project); renderer.completeProject(project); } renderer.complete(); } catch (IOException e) { throw new UncheckedIOException(e); } }
Example #2
Source File: GaugeTask.java From gauge-gradle-plugin with GNU General Public License v3.0 | 6 votes |
@TaskAction public void gauge() { Project project = getProject(); GaugeExtension extension = project.getExtensions().findByType(GaugeExtension.class); PropertyManager propertyManager = new PropertyManager(project, extension); propertyManager.setProperties(); ProcessBuilderFactory processBuilderFactory = new ProcessBuilderFactory(extension, project); ProcessBuilder builder = processBuilderFactory.create(); log.info("Executing command => " + builder.command()); try { Process process = builder.start(); executeGaugeSpecs(process); } catch (IOException e) { throw new GaugeExecutionFailedException("Gauge or Java runner is not installed! Read http://getgauge.io/documentation/user/current/getting_started/download_and_install.html"); } }
Example #3
Source File: JavaBasePlugin.java From javaide with GNU General Public License v3.0 | 6 votes |
private void configureJavaDoc(final Project project, final JavaPluginConvention convention) { project.getTasks().withType(Javadoc.class, new Action<Javadoc>() { public void execute(Javadoc javadoc) { javadoc.getConventionMapping().map("destinationDir", new Callable<Object>() { public Object call() throws Exception { return new File(convention.getDocsDir(), "javadoc"); } }); javadoc.getConventionMapping().map("title", new Callable<Object>() { public Object call() throws Exception { return project.getExtensions().getByType(ReportingExtension.class).getApiDocTitle(); } }); } }); }
Example #4
Source File: AffectedProjectFinder.java From firebase-android-sdk with Apache License 2.0 | 6 votes |
/** * Performs a post-order project tree traversal and returns a set of projects that own the * 'changedPaths'. */ private static Set<Project> changedSubProjects(Project project, Set<String> changedPaths) { // project.subprojects include all descendants of a given project, we only want immediate // children. Stream<Project> immediateChildProjects = project.getSubprojects().stream().filter(p -> project.equals(p.getParent())); Set<Project> projects = immediateChildProjects .flatMap(p -> changedSubProjects(p, changedPaths).stream()) .collect(Collectors.toSet()); String relativePath = project.getRootDir().toURI().relativize(project.getProjectDir().toURI()).toString(); Iterator<String> itr = changedPaths.iterator(); while (itr.hasNext()) { String file = itr.next(); if (file.startsWith(relativePath)) { System.out.println("Claiming file " + file + " for project " + project); itr.remove(); projects.add(project); } } return projects; }
Example #5
Source File: TaskDetailsFactory.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
public TaskDetails create(final Task task) { final String path; Project project = task.getProject(); if (projects.contains(project)) { path = this.project.relativeProjectPath(task.getPath()); } else { path = task.getPath(); } return new TaskDetails() { public Path getPath() { return Path.path(path); } public String getDescription() { return task.getDescription(); } public Set<TaskDetails> getDependencies() { return Collections.emptySet(); } public Set<TaskDetails> getChildren() { return Collections.emptySet(); } }; }
Example #6
Source File: JigsawPlugin.java From gradle-java-modules with Apache License 2.0 | 6 votes |
private void configureTestTask(final Project project) { final Test testTask = (Test) project.getTasks().findByName(JavaPlugin.TEST_TASK_NAME); final SourceSet test = ((SourceSetContainer) project.getProperties().get("sourceSets")).getByName("test"); final JavaModule module = (JavaModule) project.getExtensions().getByName(EXTENSION_NAME); testTask.getInputs().property("moduleName", module.geName()); testTask.doFirst(new Action<Task>() { @Override public void execute(Task task) { List<String> args = new ArrayList<>(); args.add("--module-path"); args.add(testTask.getClasspath().getAsPath()); args.add("--add-modules"); args.add("ALL-MODULE-PATH"); args.add("--add-reads"); args.add(module.geName() + "=junit"); args.add("--patch-module"); args.add(module.geName() + "=" + test.getJava().getOutputDir()); testTask.setJvmArgs(args); testTask.setClasspath(project.files()); } }); }
Example #7
Source File: CodelabsPlugin.java From curiostack with MIT License | 6 votes |
@Override public void apply(Project project) { project.getRootProject().getPlugins().apply(CodelabsSetupPlugin.class); project.getPlugins().apply(BasePlugin.class); var setupClaat = DownloadToolUtil.getSetupTask(project, "claat"); var exportDocs = project .getTasks() .register( "exportDocs", ExportDocsTask.class, t -> { t.dependsOn(setupClaat); var mdFileTree = project.fileTree("src"); mdFileTree.exclude("build").include("**/*.md"); t.getMdFiles().set(mdFileTree); t.getOutputDir().set(project.file("build/site")); }); project.getTasks().named("assemble").configure(t -> t.dependsOn(exportDocs)); }
Example #8
Source File: ModuleSystemPlugin.java From gradle-modules-plugin with MIT License | 6 votes |
private void configureModularity(Project project, String moduleName) { ExtensionContainer extensions = project.getExtensions(); extensions.add("moduleName", moduleName); extensions.create("patchModules", PatchModuleExtension.class); extensions.create(ModularityExtension.class, "modularity", DefaultModularityExtension.class, project); new CompileTask(project).configureCompileJava(); new CompileModuleInfoTask(project).configureCompileModuleInfoJava(); new MergeClassesTask(project).configureMergeClasses(); new CompileTestTask(project).configureCompileTestJava(); new TestTask(project).configureTestJava(); new RunTask(project).configureRun(); new JavadocTask(project).configureJavaDoc(); ModularJavaExec.configure(project); ModularCreateStartScripts.configure(project); PatchModuleContainer.configure(project); }
Example #9
Source File: TerraformPlanTask.java From gradle-plugins with Apache License 2.0 | 5 votes |
@TaskAction public void exec() { setAddVariables(true); Project project = getProject(); File planDir = project.file("build/terraform/plan"); planDir.getParentFile().mkdirs(); commandLine("plan -out=" + CONTAINER_PLAN_FILE); super.exec(); }
Example #10
Source File: CloudV2Plugin.java From commerce-gradle-plugin with Apache License 2.0 | 5 votes |
private void configureExtensionGeneration(Project project, Manifest manifest) { project.getTasks().create("generateCloudLocalextensions", GenerateLocalextensions.class, t -> { t.setGroup(GROUP); t.setDescription("generate localextensions.xml based on manifest"); t.getTarget().set(extension.getGeneratedConfiguration().file("localextensions.xml")); t.getCloudExtensions().set(manifest.extensions); }); }
Example #11
Source File: SourceSetUtils.java From transport with BSD 2-Clause "Simplified" License | 5 votes |
/** * Adds the provided dependency to the appropriate configurations of the given {@link SourceSet} */ static void addDependencyConfigurationToSourceSet(Project project, SourceSet sourceSet, DependencyConfiguration dependencyConfiguration) { addDependencyToConfiguration(project, SourceSetUtils.getConfigurationForSourceSet(project, sourceSet, dependencyConfiguration.getConfigurationType()), dependencyConfiguration.getDependencyString()); }
Example #12
Source File: ProfileEventAdapter.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public void afterExecute(Task task, TaskState state) { long now = timeProvider.getCurrentTime(); Project project = task.getProject(); ProjectProfile projectProfile = buildProfile.getProjectProfile(project.getPath()); TaskExecution taskExecution = projectProfile.getTaskProfile(task.getPath()); taskExecution.setFinish(now); taskExecution.completed(state); }
Example #13
Source File: EclipseModelBuilder.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public DefaultEclipseProject buildAll(String modelName, Project project) { boolean includeTasks = modelName.equals("org.gradle.tooling.model.eclipse.EclipseProject"); tasksFactory = new TasksFactory(includeTasks); projectDependenciesOnly = modelName.equals("org.gradle.tooling.model.eclipse.HierarchicalEclipseProject"); currentProject = project; Project root = project.getRootProject(); rootGradleProject = gradleProjectBuilder.buildAll(project); tasksFactory.collectTasks(root); applyEclipsePlugin(root); buildHierarchy(root); populate(root); return result; }
Example #14
Source File: SdkUtil.java From firebase-android-sdk with Apache License 2.0 | 5 votes |
public static File getAndroidJar(Project project) { LibraryExtension android = project.getExtensions().findByType(LibraryExtension.class); if (android == null) { throw new GradleException("Project " + project.getPath() + " is not an android library."); } return new File( getSdkDir(project), String.format("/platforms/%s/android.jar", android.getCompileSdkVersion())); }
Example #15
Source File: MutatorHelper.java From gradle-modules-plugin with MIT License | 5 votes |
public static void configureModuleVersion(JavaProjectHelper helper, List<String> args) { String version = helper.modularityExtension().optionContainer().getModuleVersion(); if(version == null) { Object projectVersion = helper.project().getVersion(); if(projectVersion != null) { version = projectVersion.toString(); } } if((version != null) && !Project.DEFAULT_VERSION.equals(version)) { new TaskOption("--module-version", version).mutateArgs(args); } }
Example #16
Source File: CloudV2Plugin.java From commerce-gradle-plugin with Apache License 2.0 | 5 votes |
private void configureWebTests(Project project, TestConfiguration test) { if (test == TestConfiguration.NO_VALUE) { return; } HybrisAntTask allWebTests = project.getTasks().create("cloudWebTests", HybrisAntTask.class, configureTest(test)); allWebTests.setArgs(Collections.singletonList("allwebtests")); allWebTests.setGroup(GROUP); allWebTests.setDescription("run ant allwebtests with manifest configuration"); }
Example #17
Source File: TaskReportRenderer.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
@Override public void startProject(Project project) { currentProjectHasTasks = false; currentProjectHasRules = false; hasContent = false; detail = false; super.startProject(project); }
Example #18
Source File: ParallelTaskPlanExecutor.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
private void startAdditionalWorkers(TaskExecutionPlan taskExecutionPlan, TaskExecutionListener taskListener, Executor executor) { List<Project> projects = getAllProjects(taskExecutionPlan); int numExecutors = Math.min(executorCount, projects.size()); LOGGER.info("Using {} parallel executor threads", numExecutors); for (int i = 1; i < numExecutors; i++) { Runnable worker = taskWorker(taskExecutionPlan, taskListener); executor.execute(worker); } }
Example #19
Source File: SemverGitflowPlugin.java From gradle-gitsemver with Apache License 2.0 | 5 votes |
public static SemverVersion getRepoVersion(Project project, String prefix) throws NoWorkTreeException, IOException, GitAPIException { String repoLocation = project.getProjectDir().getAbsolutePath() + "/.git"; Integer buildNumber = getBuildNumber(); return RepoSemanticVersions.getRepoVersion(repoLocation, buildNumber, prefix); }
Example #20
Source File: EndpointsServerExtension.java From endpoints-framework-gradle-plugin with Apache License 2.0 | 5 votes |
/** Constructor. */ public EndpointsServerExtension(Project project) { this.project = project; discoveryDocDir = new File(project.getBuildDir(), "endpointsDiscoveryDocs"); openApiDocDir = new File(project.getBuildDir(), "endpointsOpenApiDocs"); clientLibDir = new File(project.getBuildDir(), "endpointsClientLibs"); serviceClasses = new ArrayList<>(); }
Example #21
Source File: ProjectOutcomesModelBuilder.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
private DefaultProjectOutcomes buildProjectOutput(Project project, ProjectOutcomes parent) { DefaultProjectOutcomes projectOutput = new DefaultProjectOutcomes(project.getName(), project.getPath(), project.getDescription(), project.getProjectDir(), getFileOutcomes(project), parent); for (Project child : project.getChildProjects().values()) { projectOutput.addChild(buildProjectOutput(child, projectOutput)); } return projectOutput; }
Example #22
Source File: TextReportRenderer.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
protected String createHeader(Project project) { String header; if (project.getRootProject() == project) { header = "Root project"; } else { header = String.format("Project %s", project.getPath()); } if (GUtil.isTrue(project.getDescription())) { header = header + " - " + project.getDescription(); } return header; }
Example #23
Source File: ProjectReportTask.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
@Override protected void generate(Project project) throws IOException { BuildClientMetaData metaData = getClientMetaData(); StyledTextOutput textOutput = getRenderer().getTextOutput(); render(project, new GraphRenderer(textOutput), true, textOutput); if (project.getChildProjects().isEmpty()) { textOutput.withStyle(Info).text("No sub-projects"); textOutput.println(); } textOutput.println(); textOutput.text("To see a list of the tasks of a project, run "); metaData.describeCommand(textOutput.withStyle(UserInput), String.format("<project-path>:%s", ProjectInternal.TASKS_TASK)); textOutput.println(); textOutput.text("For example, try running "); Project exampleProject = project.getChildProjects().isEmpty() ? project : getChildren(project).get(0); metaData.describeCommand(textOutput.withStyle(UserInput), exampleProject.absoluteProjectPath( ProjectInternal.TASKS_TASK)); textOutput.println(); if (project != project.getRootProject()) { textOutput.println(); textOutput.text("To see a list of all the projects in this build, run "); metaData.describeCommand(textOutput.withStyle(UserInput), project.getRootProject().absoluteProjectPath( ProjectInternal.PROJECTS_TASK)); textOutput.println(); } }
Example #24
Source File: InitVersioning.java From shipkit with MIT License | 5 votes |
private String determineVersion(Project project, File versionFile) { if ("unspecified".equals(project.getVersion())) { LOG.info("'project.version' is unspecified. Version will be set to '{}'. You can change it in '{}'.", FALLBACK_INITIAL_VERSION, versionFile.getName()); return FALLBACK_INITIAL_VERSION; } else { LOG.lifecycle(" Configured '{}' version in '{}' file. Please remove 'version={}' setting from " + "*.gradle file. Version needs follow semantic versioning i.e. contains 3 numbers separated " + "by . (dot), e.g. 0.0.1 or 1.0.0 or 1.2.34 etc.", project.getVersion(), versionFile.getName(), project.getVersion()); return project.getVersion().toString(); } }
Example #25
Source File: GitVersionPlugin.java From gradle-plugins with MIT License | 5 votes |
@Override public void apply(Project project) { this.project = project; this.logger = project.getLogger(); project.setVersion(resolveVersion()); project.allprojects(p -> p.setVersion(project.getVersion())); }
Example #26
Source File: AppEnginePlugin.java From app-gradle-plugin with Apache License 2.0 | 5 votes |
@Override public void apply(Project project) { checkGradleVersion(); if (isAppEngineWebXmlBased(project)) { project.getPluginManager().apply(AppEngineStandardPlugin.class); } else { project.getPluginManager().apply(AppEngineAppYamlPlugin.class); } }
Example #27
Source File: BootPlugin.java From purplejs with Apache License 2.0 | 5 votes |
@Override public void apply( final Project project ) { this.project = project; this.ext = this.project.getExtensions().create( "purplejs", PurpleExtension.class, this.project ); addPlugins(); addRepositories(); addDependencies(); configureAppPlugin(); }
Example #28
Source File: JjdocProgramInvokerTest.java From javaccPlugin with MIT License | 5 votes |
@Before public void setUp() throws Exception { project = mock(Project.class); Configuration classpath = mock(Configuration.class); tempOutputDirectory = testFolder.newFolder("tempOutput"); programInvoker = new JjdocProgramInvoker(project, classpath, tempOutputDirectory); }
Example #29
Source File: EarPlugin.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
private void configureWithJavaPluginApplied(final Project project, final EarPluginConvention earPluginConvention, PluginContainer plugins) { plugins.withType(JavaPlugin.class, new Action<JavaPlugin>() { public void execute(JavaPlugin javaPlugin) { final JavaPluginConvention javaPluginConvention = project.getConvention().findPlugin(JavaPluginConvention.class); SourceSet sourceSet = javaPluginConvention.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME); sourceSet.getResources().srcDir(new Callable() { public Object call() throws Exception { return earPluginConvention.getAppDirName(); } }); project.getTasks().withType(Ear.class, new Action<Ear>() { public void execute(final Ear task) { task.dependsOn(new Callable<FileCollection>() { public FileCollection call() throws Exception { return javaPluginConvention.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME) .getRuntimeClasspath(); } }); task.from(new Callable<FileCollection>() { public FileCollection call() throws Exception { return javaPluginConvention.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME).getOutput(); } }); } }); } }); }
Example #30
Source File: UploadRule.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
private Upload createUploadTask(String name, final Configuration configuration, final Project project) { Upload upload = project.getTasks().create(name, Upload.class); upload.setDescription(String.format("Uploads all artifacts belonging to %s", configuration)); upload.setGroup(BasePlugin.UPLOAD_GROUP); upload.setConfiguration(configuration); upload.setUploadDescriptor(true); upload.getConventionMapping().map("descriptorDestination", new Callable<File>() { public File call() throws Exception { return new File(project.getBuildDir(), "ivy.xml"); } }); return upload; }