org.gradle.api.internal.project.ProjectInternal Java Examples
The following examples show how to use
org.gradle.api.internal.project.ProjectInternal.
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: TaskFactory.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
private TaskInternal createTaskObject(ProjectInternal project, final Class<? extends TaskInternal> type, String name, boolean generateGetters) { if (!Task.class.isAssignableFrom(type)) { throw new InvalidUserDataException(String.format( "Cannot create task of type '%s' as it does not implement the Task interface.", type.getSimpleName())); } final Class<? extends TaskInternal> generatedType; if (generateGetters) { generatedType = generator.generate(type); } else { generatedType = type; } return AbstractTask.injectIntoNewInstance(project, name, new Callable<TaskInternal>() { public TaskInternal call() throws Exception { try { return instantiator.newInstance(generatedType); } catch (ObjectInstantiationException e) { throw new TaskInstantiationException(String.format("Could not create task of type '%s'.", type.getSimpleName()), e.getCause()); } } }); }
Example #2
Source File: DependencyManagementBuildScopeServices.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
ArtifactDependencyResolver createArtifactDependencyResolver(ResolveIvyFactory resolveIvyFactory, LocalComponentFactory publishModuleDescriptorConverter, DependencyDescriptorFactory dependencyDescriptorFactory, CacheLockingManager cacheLockingManager, IvyContextManager ivyContextManager, ResolutionResultsStoreFactory resolutionResultsStoreFactory, LatestStrategy latestStrategy, ProjectRegistry<ProjectInternal> projectRegistry, ComponentIdentifierFactory componentIdentifierFactory) { ArtifactDependencyResolver resolver = new DefaultDependencyResolver( resolveIvyFactory, publishModuleDescriptorConverter, dependencyDescriptorFactory, new DefaultProjectComponentRegistry( publishModuleDescriptorConverter, projectRegistry), cacheLockingManager, ivyContextManager, resolutionResultsStoreFactory, latestStrategy); return new ErrorHandlingArtifactDependencyResolver( new ShortcircuitEmptyConfigsArtifactDependencyResolver( new SelfResolvingDependencyResolver( new CacheLockingArtifactDependencyResolver( cacheLockingManager, resolver)), componentIdentifierFactory)); }
Example #3
Source File: GradleArtifactResolvingHelper.java From wildfly-swarm with Apache License 2.0 | 6 votes |
private Set<ResolvedDependency> doResolve(final Collection<ArtifactSpec> deps) { final Configuration config = this.project.getConfigurations().detachedConfiguration(); final DependencySet dependencySet = config.getDependencies(); deps.stream() .forEach(spec -> { if (projects.containsKey(spec.groupId() + ":" + spec.artifactId() + ":" + spec.version())) { dependencySet.add(new DefaultProjectDependency((ProjectInternal) projects.get(spec.groupId() + ":" + spec.artifactId() + ":" + spec.version()), new DefaultProjectAccessListener(), false)); } else { final DefaultExternalModuleDependency d = new DefaultExternalModuleDependency(spec.groupId(), spec.artifactId(), spec.version()); final DefaultDependencyArtifact da = new DefaultDependencyArtifact(spec.artifactId(), spec.type(), spec.type(), spec.classifier(), null); d.addArtifact(da); d.getExcludeRules().add(new DefaultExcludeRule()); dependencySet.add(d); } }); return config.getResolvedConfiguration().getFirstLevelModuleDependencies(); }
Example #4
Source File: DefaultTaskContainer.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
public Task findByPath(String path) { if (!GUtil.isTrue(path)) { throw new InvalidUserDataException("A path must be specified!"); } if (!path.contains(Project.PATH_SEPARATOR)) { return findByName(path); } String projectPath = StringUtils.substringBeforeLast(path, Project.PATH_SEPARATOR); ProjectInternal project = this.project.findProject(!GUtil.isTrue(projectPath) ? Project.PATH_SEPARATOR : projectPath); if (project == null) { return null; } projectAccessListener.beforeRequestingTaskByPath(project); return project.getTasks().findByName(StringUtils.substringAfterLast(path, Project.PATH_SEPARATOR)); }
Example #5
Source File: ApplySourceSetConventions.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
public void execute(ProjectInternal project) { ProjectSourceSet projectSourceSet = project.getExtensions().getByType(ProjectSourceSet.class); for (FunctionalSourceSet functionalSourceSet : projectSourceSet) { for (LanguageSourceSet languageSourceSet : functionalSourceSet) { // Only apply default locations when none explicitly configured if (languageSourceSet.getSource().getSrcDirs().isEmpty()) { languageSourceSet.getSource().srcDir(String.format("src/%s/%s", functionalSourceSet.getName(), languageSourceSet.getName())); } } for (HeaderExportingSourceSet headerSourceSet : functionalSourceSet.withType(HeaderExportingSourceSet.class)) { // Only apply default locations when none explicitly configured if (headerSourceSet.getExportedHeaders().getSrcDirs().isEmpty()) { headerSourceSet.getExportedHeaders().srcDir(String.format("src/%s/headers", functionalSourceSet.getName())); } headerSourceSet.getImplicitHeaders().setSrcDirs(headerSourceSet.getSource().getSrcDirs()); headerSourceSet.getImplicitHeaders().include("**/*.h"); } } }
Example #6
Source File: TaskFactory.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
TaskFactory(ClassGenerator generator, ProjectInternal project, Instantiator instantiator) { this.generator = generator; this.project = project; this.instantiator = instantiator; validTaskArguments = new HashSet<String>(); validTaskArguments.add(Task.TASK_ACTION); validTaskArguments.add(Task.TASK_DEPENDS_ON); validTaskArguments.add(Task.TASK_DESCRIPTION); validTaskArguments.add(Task.TASK_GROUP); validTaskArguments.add(Task.TASK_NAME); validTaskArguments.add(Task.TASK_OVERWRITE); validTaskArguments.add(Task.TASK_TYPE); }
Example #7
Source File: DefaultTaskContainer.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
public Task findByPath(String path) { if (!GUtil.isTrue(path)) { throw new InvalidUserDataException("A path must be specified!"); } if (!path.contains(Project.PATH_SEPARATOR)) { return findByName(path); } String projectPath = StringUtils.substringBeforeLast(path, Project.PATH_SEPARATOR); ProjectInternal project = this.project.findProject(!GUtil.isTrue(projectPath) ? Project.PATH_SEPARATOR : projectPath); if (project == null) { return null; } projectAccessListener.beforeRequestingTaskByPath(project); return project.getTasks().findByName(StringUtils.substringAfterLast(path, Project.PATH_SEPARATOR)); }
Example #8
Source File: OsgiPluginConvention.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
private OsgiManifest createDefaultOsgiManifest(final ProjectInternal project) { OsgiManifest osgiManifest = project.getServices().get(Instantiator.class).newInstance(DefaultOsgiManifest.class, project.getFileResolver()); ConventionMapping mapping = ((IConventionAware) osgiManifest).getConventionMapping(); final OsgiHelper osgiHelper = new OsgiHelper(); mapping.map("version", new Callable<Object>() { public Object call() throws Exception { return osgiHelper.getVersion(project.getVersion().toString()); } }); mapping.map("name", new Callable<Object>() { public Object call() throws Exception { return project.getConvention().getPlugin(BasePluginConvention.class).getArchivesBaseName(); } }); mapping.map("symbolicName", new Callable<Object>() { public Object call() throws Exception { return osgiHelper.getBundleSymbolicName(project); } }); return osgiManifest; }
Example #9
Source File: JavaBasePlugin.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
public void apply(Project project) { project.getPlugins().apply(BasePlugin.class); project.getPlugins().apply(ReportingBasePlugin.class); project.getPlugins().apply(JavaLanguagePlugin.class); JavaPluginConvention javaConvention = new JavaPluginConvention((ProjectInternal) project, instantiator); project.getConvention().getPlugins().put("java", javaConvention); configureCompileDefaults(project, javaConvention); configureSourceSetDefaults(javaConvention); configureJavaDoc(project, javaConvention); configureTest(project, javaConvention); configureCheck(project); configureBuild(project); configureBuildNeeded(project); configureBuildDependents(project); }
Example #10
Source File: ConfigureGeneratedSourceSets.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public void execute(ProjectInternal project) { ProjectSourceSet projectSourceSet = project.getExtensions().getByType(ProjectSourceSet.class); for (FunctionalSourceSet functionalSourceSet : projectSourceSet) { for (LanguageSourceSetInternal languageSourceSet : functionalSourceSet.withType(LanguageSourceSetInternal.class)) { Task generatorTask = languageSourceSet.getGeneratorTask(); if (generatorTask != null) { languageSourceSet.builtBy(generatorTask); maybeSetSourceDir(languageSourceSet.getSource(), generatorTask, "sourceDir"); if (languageSourceSet instanceof HeaderExportingSourceSet) { maybeSetSourceDir(((HeaderExportingSourceSet) languageSourceSet).getExportedHeaders(), generatorTask, "headerDir"); } } } } }
Example #11
Source File: ToolingRegistrationAction.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public void execute(ProjectInternal project) { ToolingModelBuilderRegistry modelBuilderRegistry = project.getServices().get(ToolingModelBuilderRegistry.class); ProjectPublicationRegistry projectPublicationRegistry = project.getServices().get(ProjectPublicationRegistry.class); ProjectTaskLister taskLister = project.getServices().get(ProjectTaskLister.class); GradleProjectBuilder gradleProjectBuilder = new GradleProjectBuilder(); IdeaModelBuilder ideaModelBuilder = new IdeaModelBuilder(gradleProjectBuilder); modelBuilderRegistry.register(new EclipseModelBuilder(gradleProjectBuilder)); modelBuilderRegistry.register(ideaModelBuilder); modelBuilderRegistry.register(gradleProjectBuilder); modelBuilderRegistry.register(new GradleBuildBuilder()); modelBuilderRegistry.register(new BasicIdeaModelBuilder(ideaModelBuilder)); modelBuilderRegistry.register(new BuildInvocationsBuilder(taskLister)); modelBuilderRegistry.register(new PublicationsBuilder(projectPublicationRegistry)); }
Example #12
Source File: ClientProvidedBuildAction.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
private void ensureAllProjectsEvaluated(GradleInternal gradle) { gradle.getRootProject().allprojects((Action) new Action<ProjectInternal>() { public void execute(ProjectInternal projectInternal) { projectInternal.evaluate(); } }); }
Example #13
Source File: BuildInitAutoApplyAction.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public void execute(final ProjectInternal projectInternal) { if (projectInternal.getParent() == null) { projectInternal.getTasks().addPlaceholderAction("init", new Runnable() { public void run() { projectInternal.getPlugins().apply("build-init"); } }); } }
Example #14
Source File: ReportingExtension.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public ReportingExtension(Project project) { this.project = (ProjectInternal)project; this.baseDir = new Callable<File>() { public File call() throws Exception { return ReportingExtension.this.project.getServices(). get(FileLookup.class).getFileResolver(ReportingExtension.this.project.getBuildDir()). resolve(DEFAULT_REPORTS_DIR_NAME); } }; }
Example #15
Source File: ReportingBasePlugin.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public void apply(ProjectInternal project) { Convention convention = project.getConvention(); ReportingExtension extension = project.getExtensions().create(ReportingExtension.NAME, ReportingExtension.class, project); // This convention is deprecated convention.getPlugins().put("reportingBase", new ReportingBasePluginConvention(project, extension)); }
Example #16
Source File: GradleScopeServices.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
ServiceRegistryFactory createServiceRegistryFactory(final ServiceRegistry services) { return new ServiceRegistryFactory() { public ServiceRegistry createFor(Object domainObject) { if (domainObject instanceof ProjectInternal) { ProjectScopeServices projectScopeServices = new ProjectScopeServices(services, (ProjectInternal) domainObject); registries.add(projectScopeServices); return projectScopeServices; } throw new UnsupportedOperationException(); } }; }
Example #17
Source File: BuildInitAutoApplyAction.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public void execute(final ProjectInternal projectInternal) { if (projectInternal.getParent() == null) { projectInternal.getTasks().addPlaceholderAction("init", new Runnable() { public void run() { projectInternal.getPlugins().apply("build-init"); } }); } }
Example #18
Source File: DefaultProjectDependency.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public DefaultProjectDependency(ProjectInternal dependencyProject, String configuration, ProjectAccessListener projectAccessListener, boolean buildProjectDependencies) { super(configuration); this.dependencyProject = dependencyProject; this.projectAccessListener = projectAccessListener; this.buildProjectDependencies = buildProjectDependencies; }
Example #19
Source File: BuildScriptProcessor.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public void execute(ProjectInternal project) { LOGGER.info(String.format("Evaluating %s using %s.", project, project.getBuildScriptSource().getDisplayName())); Clock clock = new Clock(); try { ScriptPlugin configurer = configurerFactory.create(project.getBuildScriptSource(), project.getBuildscript(), project.getClassLoaderScope(), "buildscript", ProjectScript.class); configurer.apply(project); } finally { LOGGER.debug("Timing: Running the build script took " + clock.getTime()); } }
Example #20
Source File: ReportingExtension.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public ReportingExtension(Project project) { this.project = (ProjectInternal)project; this.baseDir = new Callable<File>() { public File call() throws Exception { return ReportingExtension.this.project.getServices(). get(FileLookup.class).getFileResolver(ReportingExtension.this.project.getBuildDir()). resolve(DEFAULT_REPORTS_DIR_NAME); } }; }
Example #21
Source File: GradleScopeServices.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
ServiceRegistryFactory createServiceRegistryFactory(final ServiceRegistry services) { return new ServiceRegistryFactory() { public ServiceRegistry createFor(Object domainObject) { if (domainObject instanceof ProjectInternal) { ProjectScopeServices projectScopeServices = new ProjectScopeServices(services, (ProjectInternal) domainObject); registries.add(projectScopeServices); return projectScopeServices; } throw new UnsupportedOperationException(); } }; }
Example #22
Source File: GroovyBasePlugin.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public void apply(ProjectInternal project) { this.project = project; JavaBasePlugin javaBasePlugin = project.getPlugins().apply(JavaBasePlugin.class); configureConfigurations(project); configureGroovyRuntimeExtension(); configureCompileDefaults(); configureSourceSetDefaults(javaBasePlugin); configureGroovydoc(); }
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: GroovyCompilerFactory.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public GroovyCompilerFactory(ProjectInternal project, IsolatedAntBuilder antBuilder, ClassPathRegistry classPathRegistry, DefaultJavaCompilerFactory javaCompilerFactory, CompilerDaemonManager compilerDaemonManager, InProcessCompilerDaemonFactory inProcessCompilerDaemonFactory) { this.project = project; this.antBuilder = antBuilder; this.classPathRegistry = classPathRegistry; this.javaCompilerFactory = javaCompilerFactory; this.compilerDaemonManager = compilerDaemonManager; this.inProcessCompilerDaemonFactory = inProcessCompilerDaemonFactory; }
Example #25
Source File: BuildScriptProcessor.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public void execute(ProjectInternal project) { LOGGER.info(String.format("Evaluating %s using %s.", project, project.getBuildScriptSource().getDisplayName())); Clock clock = new Clock(); try { ScriptPlugin configurer = configurerFactory.create(project.getBuildScriptSource(), project.getBuildscript(), project.getClassLoaderScope(), project.getBaseClassLoaderScope(), "buildscript", ProjectScript.class, true); configurer.apply(project); } finally { LOGGER.debug("Timing: Running the build script took " + clock.getTime()); } }
Example #26
Source File: ProjectScopeServices.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public ProjectScopeServices(final ServiceRegistry parent, final ProjectInternal project) { super(parent); this.project = project; register(new Action<ServiceRegistration>() { public void execute(ServiceRegistration registration) { registration.add(DomainObjectContext.class, project); parent.get(DependencyManagementServices.class).addDslServices(registration); for (PluginServiceRegistry pluginServiceRegistry : parent.getAll(PluginServiceRegistry.class)) { pluginServiceRegistry.registerProjectServices(registration); } } }); }
Example #27
Source File: DefaultBuildController.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public BuildResult<?> getModel(Object target, ModelIdentifier modelIdentifier) throws BuildExceptionVersion1, InternalUnsupportedModelException { BuildCancellationToken cancellationToken = gradle.getServices().get(BuildCancellationToken.class); if (cancellationToken.isCancellationRequested()) { throw new BuildCancelledException(String.format("Could not build '%s' model. Build cancelled.", modelIdentifier.getName())); } ToolingModelBuilderRegistry modelBuilderRegistry; ProjectInternal project; boolean isImplicitProject; if (target == null) { project = gradle.getDefaultProject(); isImplicitProject = true; } else if (target instanceof GradleProjectIdentity) { GradleProjectIdentity gradleProject = (GradleProjectIdentity) target; project = gradle.getRootProject().project(gradleProject.getPath()); isImplicitProject = false; } else { throw new IllegalArgumentException("Don't know how to build models for " + target); } modelBuilderRegistry = project.getServices().get(ToolingModelBuilderRegistry.class); ToolingModelBuilder builder; try { builder = modelBuilderRegistry.getBuilder(modelIdentifier.getName()); } catch (UnknownModelException e) { throw (InternalUnsupportedModelException) (new InternalUnsupportedModelException()).initCause(e); } Object model; if (builder instanceof ProjectSensitiveToolingModelBuilder) { model = ((ProjectSensitiveToolingModelBuilder) builder).buildAll(modelIdentifier.getName(), project, isImplicitProject); } else { model = builder.buildAll(modelIdentifier.getName(), project); } return new ProviderBuildResult<Object>(model); }
Example #28
Source File: TaskPathProjectEvaluator.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public void configureHierarchy(ProjectInternal project) { if (cancellationToken.isCancellationRequested()) { throw new BuildCancelledException(); } project.evaluate(); for (Project sub : project.getSubprojects()) { if (cancellationToken.isCancellationRequested()) { throw new BuildCancelledException(); } ((ProjectInternal) sub).evaluate(); } }
Example #29
Source File: SourceContextPluginTest.java From app-gradle-plugin with Apache License 2.0 | 5 votes |
@Test public void testDefaultConfiguration() throws IOException { File appengineWebXml = new File(testProjectDir.getRoot(), "src/main/webapp/WEB-INF/appengine-web.xml"); appengineWebXml.getParentFile().mkdirs(); appengineWebXml.createNewFile(); Files.write(appengineWebXml.toPath(), "<web-app/>".getBytes()); Project project = ProjectBuilder.builder().withProjectDir(testProjectDir.getRoot()).build(); project.getPluginManager().apply(JavaPlugin.class); project.getPluginManager().apply(WarPlugin.class); project.getPluginManager().apply(AppEngineStandardPlugin.class); project.getPluginManager().apply(SourceContextPlugin.class); DeployExtension deploy = project.getExtensions().getByType(AppEngineStandardExtension.class).getDeploy(); deploy.setProjectId("project"); deploy.setVersion("version"); ((ProjectInternal) project).evaluate(); ExtensionAware ext = (ExtensionAware) project.getExtensions().getByName(AppEngineCorePluginConfiguration.APPENGINE_EXTENSION); GenRepoInfoFileExtension genRepoInfoExt = new ExtensionUtil(ext).get(SourceContextPlugin.SOURCE_CONTEXT_EXTENSION); Assert.assertEquals( new File(project.getBuildDir(), "sourceContext"), genRepoInfoExt.getOutputDirectory()); }
Example #30
Source File: GradleScopeServices.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
ServiceRegistryFactory createServiceRegistryFactory(final ServiceRegistry services) { return new ServiceRegistryFactory() { public ServiceRegistry createFor(Object domainObject) { if (domainObject instanceof ProjectInternal) { ProjectScopeServices projectScopeServices = new ProjectScopeServices(services, (ProjectInternal) domainObject); registries.add(projectScopeServices); return projectScopeServices; } throw new UnsupportedOperationException(); } }; }