Search in sources :

Example 26 with ProjectInternal

use of org.gradle.api.internal.project.ProjectInternal in project gradle by gradle.

the class JavaGradlePluginPlugin method registerPlugins.

private void registerPlugins(Project project, GradlePluginDevelopmentExtension extension) {
    ProjectInternal projectInternal = (ProjectInternal) project;
    ProjectPublicationRegistry registry = projectInternal.getServices().get(ProjectPublicationRegistry.class);
    extension.getPlugins().all(pluginDeclaration -> registry.registerPublication(projectInternal, new LocalPluginPublication(pluginDeclaration)));
}
Also used : ProjectInternal(org.gradle.api.internal.project.ProjectInternal) ProjectPublicationRegistry(org.gradle.api.internal.artifacts.ivyservice.projectmodule.ProjectPublicationRegistry)

Example 27 with ProjectInternal

use of org.gradle.api.internal.project.ProjectInternal in project gradle by gradle.

the class EarPlugin method setupEarTask.

private void setupEarTask(final Project project, EarPluginConvention convention, PluginContainer plugins) {
    TaskProvider<Ear> ear = project.getTasks().register(EAR_TASK_NAME, Ear.class, new Action<Ear>() {

        @Override
        public void execute(Ear ear) {
            ear.setDescription("Generates a ear archive with all the modules, the application descriptor and the libraries.");
            ear.setGroup(BasePlugin.BUILD_GROUP);
            ear.getGenerateDeploymentDescriptor().convention(convention.getGenerateDeploymentDescriptor());
            plugins.withType(JavaPlugin.class, javaPlugin -> {
                final JavaPluginExtension javaPluginExtension = project.getExtensions().findByType(JavaPluginExtension.class);
                SourceSet sourceSet = mainSourceSetOf(javaPluginExtension);
                sourceSet.getResources().srcDir(ear.getAppDirectory());
            });
        }
    });
    DeploymentDescriptor deploymentDescriptor = convention.getDeploymentDescriptor();
    if (deploymentDescriptor != null) {
        if (deploymentDescriptor.getDisplayName() == null) {
            deploymentDescriptor.setDisplayName(project.getName());
        }
        if (deploymentDescriptor.getDescription() == null) {
            deploymentDescriptor.setDescription(project.getDescription());
        }
    }
    project.getExtensions().getByType(DefaultArtifactPublicationSet.class).addCandidate(new LazyPublishArtifact(ear, ((ProjectInternal) project).getFileResolver()));
    project.getTasks().withType(Ear.class).configureEach(new Action<Ear>() {

        @Override
        public void execute(Ear task) {
        }
    });
}
Also used : LazyPublishArtifact(org.gradle.api.internal.artifacts.dsl.LazyPublishArtifact) DefaultArtifactPublicationSet(org.gradle.api.internal.plugins.DefaultArtifactPublicationSet) Action(org.gradle.api.Action) Project(org.gradle.api.Project) JavaPlugin(org.gradle.api.plugins.JavaPlugin) Callable(java.util.concurrent.Callable) BasePlugin(org.gradle.api.plugins.BasePlugin) FileCollection(org.gradle.api.file.FileCollection) SourceSet(org.gradle.api.tasks.SourceSet) Inject(javax.inject.Inject) Configuration(org.gradle.api.artifacts.Configuration) ObjectFactory(org.gradle.api.model.ObjectFactory) ConfigurationContainer(org.gradle.api.artifacts.ConfigurationContainer) TaskProvider(org.gradle.api.tasks.TaskProvider) ProjectInternal(org.gradle.api.internal.project.ProjectInternal) JavaPluginExtension(org.gradle.api.plugins.JavaPluginExtension) PluginContainer(org.gradle.api.plugins.PluginContainer) DeploymentDescriptor(org.gradle.plugins.ear.descriptor.DeploymentDescriptor) Dependency(org.gradle.api.artifacts.Dependency) Plugin(org.gradle.api.Plugin) JvmPluginServices(org.gradle.api.plugins.jvm.internal.JvmPluginServices) SourceSet(org.gradle.api.tasks.SourceSet) DefaultArtifactPublicationSet(org.gradle.api.internal.plugins.DefaultArtifactPublicationSet) LazyPublishArtifact(org.gradle.api.internal.artifacts.dsl.LazyPublishArtifact) DeploymentDescriptor(org.gradle.plugins.ear.descriptor.DeploymentDescriptor) ProjectInternal(org.gradle.api.internal.project.ProjectInternal) JavaPlugin(org.gradle.api.plugins.JavaPlugin) JavaPluginExtension(org.gradle.api.plugins.JavaPluginExtension)

Example 28 with ProjectInternal

use of org.gradle.api.internal.project.ProjectInternal in project gradle by gradle.

the class EclipseModelBuilder method gatherExternalProjects.

private List<EclipseWorkspaceProject> gatherExternalProjects(ProjectInternal rootProject, List<EclipseWorkspaceProject> projects) {
    // The eclipse workspace contains projects from root and included builds. Check projects from all builds
    // so that models built for included builds do not consider projects from parent builds as external.
    Set<File> gradleProjectLocations = collectAllProjects(new ArrayList<>(), getRootBuild(rootProject.getGradle()), new HashSet<>()).stream().map(p -> p.getProjectDir().getAbsoluteFile()).collect(Collectors.toSet());
    List<EclipseWorkspaceProject> externalProjects = new ArrayList<>();
    for (EclipseWorkspaceProject project : projects) {
        if (project == null || project.getLocation() == null || project.getName() == null || project.getLocation() == null) {
            continue;
        }
        if (!gradleProjectLocations.contains(project.getLocation().getAbsoluteFile())) {
            externalProjects.add(project);
        }
    }
    return externalProjects;
}
Also used : TaskDependency(org.gradle.api.tasks.TaskDependency) CollectionUtils(org.gradle.util.internal.CollectionUtils) StringUtils(org.apache.commons.lang.StringUtils) DefaultEclipseOutputLocation(org.gradle.plugins.ide.internal.tooling.eclipse.DefaultEclipseOutputLocation) ProjectStateRegistry(org.gradle.api.internal.project.ProjectStateRegistry) BuildState(org.gradle.internal.build.BuildState) Link(org.gradle.plugins.ide.eclipse.model.Link) DefaultAccessRule(org.gradle.plugins.ide.internal.tooling.eclipse.DefaultAccessRule) EclipsePlugin(org.gradle.plugins.ide.eclipse.EclipsePlugin) GUtil(org.gradle.util.internal.GUtil) Task(org.gradle.api.Task) Container(org.gradle.plugins.ide.eclipse.model.Container) ProjectInternal(org.gradle.api.internal.project.ProjectInternal) Map(java.util.Map) XmlTransformer(org.gradle.internal.xml.XmlTransformer) DefaultEclipseSourceDirectory(org.gradle.plugins.ide.internal.tooling.eclipse.DefaultEclipseSourceDirectory) DefaultEclipseExternalDependency(org.gradle.plugins.ide.internal.tooling.eclipse.DefaultEclipseExternalDependency) EclipseJdt(org.gradle.plugins.ide.eclipse.model.EclipseJdt) EclipseClasspath(org.gradle.plugins.ide.eclipse.model.EclipseClasspath) DefaultEclipseProjectNature(org.gradle.plugins.ide.internal.tooling.eclipse.DefaultEclipseProjectNature) Project(org.gradle.api.Project) Classpath(org.gradle.plugins.ide.eclipse.model.Classpath) DefaultClasspathAttribute(org.gradle.plugins.ide.internal.tooling.eclipse.DefaultClasspathAttribute) Set(java.util.Set) Collectors(java.util.stream.Collectors) Gradle(org.gradle.api.invocation.Gradle) SourceFolder(org.gradle.plugins.ide.eclipse.model.SourceFolder) XmlFileContentMerger(org.gradle.plugins.ide.api.XmlFileContentMerger) List(java.util.List) Spec(org.gradle.api.specs.Spec) ParameterizedToolingModelBuilder(org.gradle.tooling.provider.model.ParameterizedToolingModelBuilder) DefaultEclipseTask(org.gradle.plugins.ide.internal.tooling.eclipse.DefaultEclipseTask) EclipseRuntime(org.gradle.tooling.model.eclipse.EclipseRuntime) AbstractClasspathEntry(org.gradle.plugins.ide.eclipse.model.AbstractClasspathEntry) EclipseModelAwareUniqueProjectNameProvider(org.gradle.plugins.ide.internal.configurer.EclipseModelAwareUniqueProjectNameProvider) DefaultEclipseBuildCommand(org.gradle.plugins.ide.internal.tooling.eclipse.DefaultEclipseBuildCommand) IncludedBuildInternal(org.gradle.internal.composite.IncludedBuildInternal) Library(org.gradle.plugins.ide.eclipse.model.Library) HashMap(java.util.HashMap) DefaultEclipseClasspathContainer(org.gradle.plugins.ide.internal.tooling.eclipse.DefaultEclipseClasspathContainer) ArrayList(java.util.ArrayList) AbstractLibrary(org.gradle.plugins.ide.eclipse.model.AbstractLibrary) DefaultEclipseLinkedResource(org.gradle.plugins.ide.internal.tooling.eclipse.DefaultEclipseLinkedResource) HashSet(java.util.HashSet) EclipseWorkspaceProject(org.gradle.tooling.model.eclipse.EclipseWorkspaceProject) Lists(com.google.common.collect.Lists) AccessRule(org.gradle.plugins.ide.eclipse.model.AccessRule) UnsupportedMethodException(org.gradle.tooling.model.UnsupportedMethodException) LinkedList(java.util.LinkedList) GradleInternal(org.gradle.api.internal.GradleInternal) EclipseWorkspace(org.gradle.tooling.model.eclipse.EclipseWorkspace) EclipseModel(org.gradle.plugins.ide.eclipse.model.EclipseModel) DefaultEclipseProjectDependency(org.gradle.plugins.ide.internal.tooling.eclipse.DefaultEclipseProjectDependency) Maps(com.google.common.collect.Maps) ClasspathEntry(org.gradle.plugins.ide.eclipse.model.ClasspathEntry) File(java.io.File) UnresolvedLibrary(org.gradle.plugins.ide.eclipse.model.UnresolvedLibrary) DefaultGradleProject(org.gradle.plugins.ide.internal.tooling.model.DefaultGradleProject) Output(org.gradle.plugins.ide.eclipse.model.Output) DefaultEclipseProject(org.gradle.plugins.ide.internal.tooling.eclipse.DefaultEclipseProject) DefaultInstalledJdk(org.gradle.plugins.ide.internal.tooling.java.DefaultInstalledJdk) ProjectDependency(org.gradle.plugins.ide.eclipse.model.ProjectDependency) BuildCommand(org.gradle.plugins.ide.eclipse.model.BuildCommand) DefaultEclipseJavaSourceSettings(org.gradle.plugins.ide.internal.tooling.eclipse.DefaultEclipseJavaSourceSettings) VisibleForTesting(com.google.common.annotations.VisibleForTesting) Collections(java.util.Collections) IncludedBuildState(org.gradle.internal.build.IncludedBuildState) EclipseWorkspaceProject(org.gradle.tooling.model.eclipse.EclipseWorkspaceProject) ArrayList(java.util.ArrayList) File(java.io.File) HashSet(java.util.HashSet)

Example 29 with ProjectInternal

use of org.gradle.api.internal.project.ProjectInternal in project gradle by gradle.

the class JvmEcosystemPlugin method apply.

@Override
public void apply(Project project) {
    ProjectInternal p = (ProjectInternal) project;
    project.getExtensions().add(SourceSetContainer.class, "sourceSets", sourceSets);
    configureVariantDerivationStrategy(p);
    configureSchema(p);
    jvmPluginServices.inject(p, sourceSets);
}
Also used : ProjectInternal(org.gradle.api.internal.project.ProjectInternal)

Example 30 with ProjectInternal

use of org.gradle.api.internal.project.ProjectInternal in project gradle by gradle.

the class DefaultConfiguration method toRootComponentMetaData.

public ComponentResolveMetadata toRootComponentMetaData() {
    Module module = getModule();
    ComponentIdentifier componentIdentifier = componentIdentifierFactory.createComponentIdentifier(module);
    ModuleVersionIdentifier moduleVersionIdentifier = moduleIdentifierFactory.moduleWithVersion(module.getGroup(), module.getName(), module.getVersion());
    ProjectInternal project = projectFinder.findProject(module.getProjectPath());
    AttributesSchemaInternal schema = project == null ? null : (AttributesSchemaInternal) project.getDependencies().getAttributesSchema();
    DefaultLocalComponentMetadata metaData = new DefaultLocalComponentMetadata(moduleVersionIdentifier, componentIdentifier, module.getStatus(), schema);
    configurationComponentMetaDataBuilder.addConfigurations(metaData, configurationsProvider.getAll());
    return metaData;
}
Also used : ModuleVersionIdentifier(org.gradle.api.artifacts.ModuleVersionIdentifier) DefaultLocalComponentMetadata(org.gradle.internal.component.local.model.DefaultLocalComponentMetadata) ProjectInternal(org.gradle.api.internal.project.ProjectInternal) ComponentIdentifier(org.gradle.api.artifacts.component.ComponentIdentifier) Module(org.gradle.api.internal.artifacts.Module) AttributesSchemaInternal(org.gradle.api.internal.attributes.AttributesSchemaInternal)

Aggregations

ProjectInternal (org.gradle.api.internal.project.ProjectInternal)58 File (java.io.File)13 Project (org.gradle.api.Project)11 Task (org.gradle.api.Task)6 ServiceRegistry (org.gradle.internal.service.ServiceRegistry)6 Inject (javax.inject.Inject)5 Plugin (org.gradle.api.Plugin)5 ProjectStateRegistry (org.gradle.api.internal.project.ProjectStateRegistry)5 Map (java.util.Map)4 Configuration (org.gradle.api.artifacts.Configuration)4 FileResolver (org.gradle.api.internal.file.FileResolver)4 Lists (com.google.common.collect.Lists)3 ArrayList (java.util.ArrayList)3 Collections (java.util.Collections)3 HashSet (java.util.HashSet)3 List (java.util.List)3 Set (java.util.Set)3 Callable (java.util.concurrent.Callable)3 Collectors (java.util.stream.Collectors)3 FileCollectionFactory (org.gradle.api.internal.file.FileCollectionFactory)3