Java Code Examples for org.gradle.api.Project
The following examples show how to use
org.gradle.api.Project.
These examples are extracted from open source projects.
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 Project: firebase-android-sdk Author: firebase File: AffectedProjectFinder.java License: 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 #2
Source Project: javaide Author: tranleduy2000 File: JavaBasePlugin.java License: 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 #3
Source Project: gradle-java-modules Author: gradle File: JigsawPlugin.java License: 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 #4
Source Project: pushfish-android Author: PushFish File: AbstractReportTask.java License: 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 #5
Source Project: gauge-gradle-plugin Author: manupsunny File: GaugeTask.java License: 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 #6
Source Project: Pushjet-Android Author: Pushjet File: TaskDetailsFactory.java License: 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 #7
Source Project: gradle-modules-plugin Author: java9-modularity File: ModuleSystemPlugin.java License: 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 #8
Source Project: curiostack Author: curioswitch File: CodelabsPlugin.java License: 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 #9
Source Project: transport Author: linkedin File: SourceSetUtils.java License: 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 #10
Source Project: thorntail Author: thorntail File: GradleDependencyResolutionHelper.java License: Apache License 2.0 | 5 votes |
/** * Get the collection of Gradle projects along with their GAV definitions. This collection is used for determining if an * artifact specification represents a Gradle project or not. * * @param project the Gradle project that is being analyzed. * @return a map of GAV coordinates for each of the available projects (returned as keys). */ private static Map<String, Project> getAllProjects(final Project project) { return getCachedReference(project, "thorntail_project_gav_collection", () -> { Map<String, Project> gavMap = new HashMap<>(); project.getRootProject().getAllprojects().forEach(p -> { gavMap.put(p.getGroup() + ":" + p.getName() + ":" + p.getVersion(), p); }); return gavMap; }); }
Example #11
Source Project: curiostack Author: curioswitch File: WebExtension.java License: MIT License | 5 votes |
static ModifiableWebExtension createAndAdd(Project project) { return project .getExtensions() .create(NAME, ModifiableWebExtension.class) .setJavaPackage(project.getObjects().property(String.class)) .setStorybookJavaPackage(project.getObjects().property(String.class)); }
Example #12
Source Project: pygradle Author: linkedin File: PipConfFile.java License: Apache License 2.0 | 5 votes |
public PipConfFile(Project project, PythonDetails pythonDetails) { this.project = project; this.pythonDetails = pythonDetails; if (OperatingSystem.current().isWindows()) { fileExtension = "ini"; } else { fileExtension = "conf"; } }
Example #13
Source Project: shrinker Author: yrom File: ShrinkerPlugin.java License: Apache License 2.0 | 5 votes |
@Override public void apply(Project project) { if (!project.getPlugins().hasPlugin(AppPlugin.class)) { throw new UnsupportedOperationException("Plugin 'shrinker' can only apply with 'com.android.application'"); } AppExtension android = project.getExtensions().getByType(AppExtension.class); ShrinkerExtension config = project.getExtensions().create("shrinker", ShrinkerExtension.class); android.registerTransform(new InlineRTransform(config)); }
Example #14
Source Project: scaffold-clean-architecture Author: bancolombia File: DeleteModuleTaskTest.java License: MIT License | 5 votes |
@Before public void setup() throws IOException, CleanException { Project project = ProjectBuilder.builder() .withName("cleanArchitecture") .withProjectDir(new File("build/unitTest")) .build(); project.getTasks().create("ca", GenerateStructureTask.class); GenerateStructureTask generateStructureTask = (GenerateStructureTask) project.getTasks().getByName("ca"); generateStructureTask.generateStructureTask(); ProjectBuilder.builder() .withName("app-service") .withProjectDir(new File("build/unitTest/applications/app-service")) .withParent(project) .build(); project.getTasks().create("gda", GenerateDrivenAdapterTask.class); GenerateDrivenAdapterTask generateDriven = (GenerateDrivenAdapterTask) project.getTasks().getByName("gda"); generateDriven.setType(ModuleFactoryDrivenAdapter.DrivenAdapterType.MONGODB); generateDriven.generateDrivenAdapterTask(); ProjectBuilder.builder() .withName("mongo-repository") .withProjectDir(new File("build/unitTest/infrastructure/driven-adapters/mongo-repository")) .withParent(project) .build(); assertTrue(new File("build/unitTest/infrastructure/driven-adapters/mongo-repository/build.gradle").exists()); project.getTasks().create("test", DeleteModuleTask.class); task = (DeleteModuleTask) project.getTasks().getByName("test"); }
Example #15
Source Project: Pushjet-Android Author: Pushjet File: EarPlugin.java License: BSD 2-Clause "Simplified" License | 5 votes |
private void setupEarTask(final Project project, EarPluginConvention convention) { Ear ear = project.getTasks().create(EAR_TASK_NAME, Ear.class); ear.setDescription("Generates a ear archive with all the modules, the application descriptor and the libraries."); DeploymentDescriptor deploymentDescriptor = convention.getDeploymentDescriptor(); if (deploymentDescriptor != null) { if (deploymentDescriptor.getDisplayName() == null) { deploymentDescriptor.setDisplayName(project.getName()); } if (deploymentDescriptor.getDescription() == null) { deploymentDescriptor.setDescription(project.getDescription()); } } ear.setGroup(BasePlugin.BUILD_GROUP); project.getExtensions().getByType(DefaultArtifactPublicationSet.class).addCandidate(new ArchivePublishArtifact(ear)); project.getTasks().withType(Ear.class, new Action<Ear>() { public void execute(Ear task) { task.getLib().from(new Callable<FileCollection>() { public FileCollection call() throws Exception { return project.getConfigurations().getByName(EARLIB_CONFIGURATION_NAME); } }); task.from(new Callable<FileCollection>() { public FileCollection call() throws Exception { // add the module configuration's files return project.getConfigurations().getByName(DEPLOY_CONFIGURATION_NAME); } }); } }); }
Example #16
Source Project: Pushjet-Android Author: Pushjet File: GroovyPlugin.java License: BSD 2-Clause "Simplified" License | 5 votes |
private void configureGroovydoc(final Project project) { Groovydoc groovyDoc = project.getTasks().create(GROOVYDOC_TASK_NAME, Groovydoc.class); groovyDoc.setDescription("Generates Groovydoc API documentation for the main source code."); groovyDoc.setGroup(JavaBasePlugin.DOCUMENTATION_GROUP); JavaPluginConvention convention = project.getConvention().getPlugin(JavaPluginConvention.class); SourceSet sourceSet = convention.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME); groovyDoc.setClasspath(sourceSet.getOutput().plus(sourceSet.getCompileClasspath())); GroovySourceSet groovySourceSet = new DslObject(sourceSet).getConvention().getPlugin(GroovySourceSet.class); groovyDoc.setSource(groovySourceSet.getGroovy()); }
Example #17
Source Project: gradle-gitsemver Author: palantir File: SemverGitflowPlugin.java License: Apache License 2.0 | 5 votes |
public static SemverVersion getRepoTopoVersion(Project project) throws NoWorkTreeException, IOException, GitAPIException { String repoLocation = project.getProjectDir().getAbsolutePath() + "/.git"; Integer buildNumber = getBuildNumber(); return RepoSemanticVersions.getRepoTopoVersion(repoLocation, buildNumber); }
Example #18
Source Project: firebase-android-sdk Author: firebase File: SdkUtil.java License: 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 #19
Source Project: endpoints-framework-gradle-plugin Author: GoogleCloudPlatform File: EndpointsServerExtension.java License: 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 #20
Source Project: Pushjet-Android Author: Pushjet File: ProjectOutcomesModelBuilder.java License: 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 #21
Source Project: gradle-plugins Author: freefair File: GitVersionPlugin.java License: 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 #22
Source Project: app-gradle-plugin Author: GoogleCloudPlatform File: AppEnginePlugin.java License: 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 #23
Source Project: purplejs Author: purplejs File: BootPlugin.java License: 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 #24
Source Project: javaccPlugin Author: johnmartel File: JjdocProgramInvokerTest.java License: 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 #25
Source Project: Pushjet-Android Author: Pushjet File: EarPlugin.java License: 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 #26
Source Project: Pushjet-Android Author: Pushjet File: ParallelTaskPlanExecutor.java License: 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 #27
Source Project: Pushjet-Android Author: Pushjet File: UploadRule.java License: 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; }
Example #28
Source Project: shipkit Author: mockito File: InitVersioning.java License: 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 #29
Source Project: pushfish-android Author: PushFish File: ProjectReportTask.java License: 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 #30
Source Project: Pushjet-Android Author: Pushjet File: TextReportRenderer.java License: 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; }