org.gradle.tooling.model.GradleProject Java Examples
The following examples show how to use
org.gradle.tooling.model.GradleProject.
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: BuildInvocationsConverter.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
private List<BasicGradleTaskSelector> buildRecursively(GradleProject project) { Multimap<String, String> aggregatedTasks = ArrayListMultimap.create(); for (GradleProject childProject : project.getChildren()) { List<BasicGradleTaskSelector> childSelectors = buildRecursively(childProject); for (BasicGradleTaskSelector childSelector : childSelectors) { aggregatedTasks.putAll(childSelector.getName(), childSelector.getTaskNames()); } } for (GradleTask task : project.getTasks()) { aggregatedTasks.put(task.getName(), task.getPath()); } List<BasicGradleTaskSelector> selectors = Lists.newArrayList(); for (String selectorName : aggregatedTasks.keySet()) { SortedSet<String> selectorTasks = Sets.newTreeSet(new TaskNameComparator()); selectorTasks.addAll(aggregatedTasks.get(selectorName)); selectors.add(new BasicGradleTaskSelector(). setName(selectorName). setTaskNames(selectorTasks). setDescription(project.getParent() != null ? String.format("%s:%s task selector", project.getPath(), selectorName) : String.format("%s task selector", selectorName)). setDisplayName(String.format("%s in %s and subprojects.", selectorName, project.getName()))); } return selectors; }
Example #2
Source File: BuildInvocationsConverter.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
private List<BasicGradleTaskSelector> buildRecursively(GradleProject project) { Multimap<String, String> aggregatedTasks = ArrayListMultimap.create(); for (GradleProject childProject : project.getChildren()) { List<BasicGradleTaskSelector> childSelectors = buildRecursively(childProject); for (BasicGradleTaskSelector childSelector : childSelectors) { aggregatedTasks.putAll(childSelector.getName(), childSelector.getTaskNames()); } } for (GradleTask task : project.getTasks()) { aggregatedTasks.put(task.getName(), task.getPath()); } List<BasicGradleTaskSelector> selectors = Lists.newArrayList(); for (String selectorName : aggregatedTasks.keySet()) { SortedSet<String> selectorTasks = Sets.newTreeSet(new TaskNameComparator()); selectorTasks.addAll(aggregatedTasks.get(selectorName)); selectors.add(new BasicGradleTaskSelector(). setName(selectorName). setTaskNames(selectorTasks). setDescription(project.getParent() != null ? String.format("%s:%s task selector", project.getPath(), selectorName) : String.format("%s task selector", selectorName)). setDisplayName(String.format("%s in %s and subprojects.", selectorName, project.getName()))); } return selectors; }
Example #3
Source File: IgnoreBuildDirContribution.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
/** * Store the build dir for the given project. */ @Override public void configure(ProjectContext context, IProgressMonitor monitor) { /* * Implementation note: This is called for each project in the workspace that * participates in a Gradle build. We keep track of the gradle build dir and the * Eclipse project to allow efficient rejection of the build dir when the Xtext * builder runs. */ IProject project = context.getProject(); Optional<GradleBuild> gradleBuild = GradleCore.getWorkspace().getBuild(project); if (gradleBuild.isPresent()) { try { GradleProject gradleProject = gradleBuild.get().withConnection( connection -> connection.getModel(GradleProject.class), new NullProgressMonitor()); File buildDirectory = gradleProject.getBuildDirectory(); File projectDirectory = gradleProject.getProjectDirectory(); IPath relativePath = Path.fromOSString(projectDirectory.toPath().relativize(buildDirectory.toPath()).toString()); IFolder buildDirAsFolder = project.getFolder(relativePath); buildDirs.add(buildDirAsFolder); buildDirsPerProject.put(project, buildDirAsFolder); } catch (Exception e) { e.printStackTrace(); } } }
Example #4
Source File: BuildInvocationsConverter.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
private List<ConsumerProvidedTaskSelector> buildRecursively(GradleProject project) { Multimap<String, String> aggregatedTasks = ArrayListMultimap.create(); collectTasks(project, aggregatedTasks); List<ConsumerProvidedTaskSelector> selectors = Lists.newArrayList(); for (String selectorName : aggregatedTasks.keySet()) { SortedSet<String> selectorTasks = Sets.newTreeSet(new TaskNameComparator()); selectorTasks.addAll(aggregatedTasks.get(selectorName)); selectors.add(new ConsumerProvidedTaskSelector(). setName(selectorName). setTaskNames(selectorTasks). setDescription(project.getParent() != null ? String.format("%s:%s task selector", project.getPath(), selectorName) : String.format("%s task selector", selectorName)). setDisplayName(String.format("%s in %s and subprojects.", selectorName, project.getName()))); } return selectors; }
Example #5
Source File: BuildInvocationsConverter.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
private List<ConsumerProvidedTaskSelector> buildRecursively(GradleProject project) { Multimap<String, String> aggregatedTasks = ArrayListMultimap.create(); collectTasks(project, aggregatedTasks); List<ConsumerProvidedTaskSelector> selectors = Lists.newArrayList(); for (String selectorName : aggregatedTasks.keySet()) { SortedSet<String> selectorTasks = Sets.newTreeSet(new TaskNameComparator()); selectorTasks.addAll(aggregatedTasks.get(selectorName)); selectors.add(new ConsumerProvidedTaskSelector(). setName(selectorName). setTaskNames(selectorTasks). setDescription(project.getParent() != null ? String.format("%s:%s task selector", project.getPath(), selectorName) : String.format("%s task selector", selectorName)). setDisplayName(String.format("%s in %s and subprojects.", selectorName, project.getName()))); } return selectors; }
Example #6
Source File: BuildActionRunnerBackedConsumerConnection.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
@Override public boolean maySupportModel(Class<?> modelType) { return modelType.equals(ProjectOutcomes.class) || modelType.equals(HierarchicalEclipseProject.class) || modelType.equals(EclipseProject.class) || modelType.equals(IdeaProject.class) || modelType.equals(BasicIdeaProject.class) || modelType.equals(BuildEnvironment.class) || modelType.equals(GradleProject.class) || modelType.equals(Void.class); }
Example #7
Source File: BuildInvocationsAdapterProducer.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public <T> T produceModel(Class<T> type, ConsumerOperationParameters operationParameters) { if (type.equals(BuildInvocations.class)) { if (!versionDetails.maySupportModel(GradleProject.class)) { throw Exceptions.unsupportedModel(type, versionDetails.getVersion()); } GradleProject gradleProject = delegate.produceModel(GradleProject.class, operationParameters); return adapter.adapt(type, new BuildInvocationsConverter().convert(gradleProject)); } return delegate.produceModel(type, operationParameters); }
Example #8
Source File: ModelMapping.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
static void addModelNameMappings(Map<Class<?>, String> map) { map.put(HierarchicalEclipseProject.class, "org.gradle.tooling.model.eclipse.HierarchicalEclipseProject"); map.put(EclipseProject.class, "org.gradle.tooling.model.eclipse.EclipseProject"); map.put(IdeaProject.class, "org.gradle.tooling.model.idea.IdeaProject"); map.put(GradleProject.class, "org.gradle.tooling.model.GradleProject"); map.put(BasicIdeaProject.class, "org.gradle.tooling.model.idea.BasicIdeaProject"); map.put(BuildEnvironment.class, "org.gradle.tooling.model.build.BuildEnvironment"); map.put(ProjectOutcomes.class, "org.gradle.tooling.model.outcomes.ProjectOutcomes"); map.put(Void.class, Void.class.getName()); }
Example #9
Source File: ModelMapping.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
static void addModelToProtocolMappings(Map<Class<?>, Class<?>> map) { map.put(HierarchicalEclipseProject.class, HierarchicalEclipseProjectVersion1.class); map.put(EclipseProject.class, EclipseProjectVersion3.class); map.put(IdeaProject.class, InternalIdeaProject.class); map.put(GradleProject.class, InternalGradleProject.class); map.put(BasicIdeaProject.class, InternalBasicIdeaProject.class); map.put(BuildEnvironment.class, InternalBuildEnvironment.class); map.put(ProjectOutcomes.class, InternalProjectOutcomes.class); map.put(Void.class, Void.class); }
Example #10
Source File: ModelMapping.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
private static void addModelVersions(Map<Class<?>, String> map) { map.put(HierarchicalEclipseProject.class, "1.0-milestone-3"); map.put(EclipseProject.class, "1.0-milestone-3"); map.put(IdeaProject.class, "1.0-milestone-5"); map.put(GradleProject.class, "1.0-milestone-5"); map.put(BasicIdeaProject.class, "1.0-milestone-5"); map.put(BuildEnvironment.class, "1.0-milestone-8"); map.put(ProjectOutcomes.class, "1.2"); map.put(Void.class, "1.0-milestone-3"); map.put(GradleBuild.class, "1.8"); }
Example #11
Source File: InternalConnectionBackedConsumerConnection.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
@Override public boolean maySupportModel(Class<?> modelType) { return modelType.equals(Void.class) || modelType.equals(HierarchicalEclipseProject.class) || modelType.equals(EclipseProject.class) || modelType.equals(IdeaProject.class) || modelType.equals(BasicIdeaProject.class) || modelType.equals(GradleProject.class) || modelType.equals(BuildEnvironment.class); }
Example #12
Source File: GradleBuildAdapterProducer.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public <T> T produceModel(Class<T> type, ConsumerOperationParameters operationParameters) { if (type.equals(GradleBuild.class)) { GradleProject gradleProject = delegate.produceModel(GradleProject.class, operationParameters); final DefaultGradleBuild convert = new GradleBuildConverter().convert(gradleProject); return adapter.adapt(type, convert); } return delegate.produceModel(type, operationParameters); }
Example #13
Source File: GradleConnector.java From MSPaintIDE with MIT License | 5 votes |
public List<GradleTask> getGradleTasks() { List<GradleTask> tasks; try (ProjectConnection connection = connector.connect()) { GradleProject project = connection.getModel(GradleProject.class); tasks = new ArrayList<>(project.getTasks()); } return tasks; }
Example #14
Source File: BuildInvocationsConverter.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public DefaultBuildInvocations<DefaultGradleTask> convert(GradleProject project) { GradleProject rootProject = project; while (rootProject.getParent() != null) { rootProject = rootProject.getParent(); } List<BasicGradleTaskSelector> selectors = buildRecursively(rootProject); return new DefaultBuildInvocations<DefaultGradleTask>() .setSelectors(selectors) .setTasks(convertTasks(rootProject.getTasks().iterator())); }
Example #15
Source File: GradleBuildConverter.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
private void convertChildren(DefaultGradleBuild gradleBuild, PartialBasicGradleProject rootProject, GradleProject project) { final List<? extends GradleProject> childProjects = new ArrayList<GradleProject>(project.getChildren()); Collections.sort(childProjects, new Comparator<GradleProject>() { public int compare(GradleProject gp1, GradleProject gp2) { return gp1.getName().compareTo(gp2.getName()); } }); for (GradleProject childProject : childProjects) { PartialBasicGradleProject basicGradleProject = toPartialGradleProject(childProject); gradleBuild.addProject(basicGradleProject); basicGradleProject.setParent(rootProject); rootProject.addChild(basicGradleProject); convertChildren(gradleBuild, basicGradleProject, childProject); } }
Example #16
Source File: BuildInvocationsConverter.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
private void collectTasks(GradleProject project, Multimap<String, String> aggregatedTasks) { for (GradleProject childProject : project.getChildren()) { collectTasks(childProject, aggregatedTasks); } for (GradleTask task : project.getTasks()) { aggregatedTasks.put(task.getName(), task.getPath()); } }
Example #17
Source File: BuildActionRunnerBackedConsumerConnection.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
@Override public boolean maySupportModel(Class<?> modelType) { return modelType.equals(ProjectOutcomes.class) || modelType.equals(HierarchicalEclipseProject.class) || modelType.equals(EclipseProject.class) || modelType.equals(IdeaProject.class) || modelType.equals(BasicIdeaProject.class) || modelType.equals(BuildEnvironment.class) || modelType.equals(GradleProject.class) || modelType.equals(Void.class); }
Example #18
Source File: BuildInvocationsAdapterProducer.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public <T> T produceModel(Class<T> type, ConsumerOperationParameters operationParameters) { if (type.getName().equals(BuildInvocations.class.getName()) && !versionDetails.maySupportModel(type)) { if (!versionDetails.maySupportModel(GradleProject.class)) { throw Exceptions.unsupportedModel(type, versionDetails.getVersion()); } GradleProject gradleProject = delegate.produceModel(GradleProject.class, operationParameters); DefaultBuildInvocations<DefaultGradleTask> convert = new BuildInvocationsConverter().convert(gradleProject); return adapter.adapt(type, convert); } return delegate.produceModel(type, operationParameters); }
Example #19
Source File: InternalConnectionBackedConsumerConnection.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
@Override public boolean maySupportModel(Class<?> modelType) { return modelType.equals(Void.class) || modelType.equals(HierarchicalEclipseProject.class) || modelType.equals(EclipseProject.class) || modelType.equals(IdeaProject.class) || modelType.equals(BasicIdeaProject.class) || modelType.equals(GradleProject.class) || modelType.equals(BuildEnvironment.class); }
Example #20
Source File: BuildActionRunnerBackedConsumerConnection.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
@Override public boolean maySupportModel(Class<?> modelType) { return modelType.equals(ProjectOutcomes.class) || modelType.equals(HierarchicalEclipseProject.class) || modelType.equals(EclipseProject.class) || modelType.equals(IdeaProject.class) || modelType.equals(BasicIdeaProject.class) || modelType.equals(BuildEnvironment.class) || modelType.equals(GradleProject.class) || modelType.equals(Void.class); }
Example #21
Source File: BuildInvocationsConverter.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public ConsumerProvidedBuildInvocations convert(GradleProject project) { GradleProject rootProject = project; while (rootProject.getParent() != null) { rootProject = rootProject.getParent(); } List<ConsumerProvidedTaskSelector> selectors = buildRecursively(rootProject); return new ConsumerProvidedBuildInvocations(selectors, convertTasks(rootProject.getTasks())); }
Example #22
Source File: BuildInvocationsConverter.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
private void collectTasks(GradleProject project, Multimap<String, String> aggregatedTasks) { for (GradleProject childProject : project.getChildren()) { collectTasks(childProject, aggregatedTasks); } for (GradleTask task : project.getTasks()) { aggregatedTasks.put(task.getName(), task.getPath()); } }
Example #23
Source File: GradleBuildConverter.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public DefaultGradleBuild convert(GradleProject project) { DefaultGradleBuild gradleBuild = new DefaultGradleBuild(); PartialBasicGradleProject rootProject = toPartialGradleProject(project); gradleBuild.setRootProject(rootProject); gradleBuild.addProject(rootProject); convertChildren(gradleBuild, rootProject, project); return gradleBuild; }
Example #24
Source File: GradleBuildConverter.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
private void convertChildren(DefaultGradleBuild gradleBuild, PartialBasicGradleProject rootProject, GradleProject project) { final List<? extends GradleProject> childProjects = new ArrayList<GradleProject>(project.getChildren()); Collections.sort(childProjects, new Comparator<GradleProject>() { public int compare(GradleProject gp1, GradleProject gp2) { return gp1.getName().compareTo(gp2.getName()); } }); for (GradleProject childProject : childProjects) { PartialBasicGradleProject basicGradleProject = toPartialGradleProject(childProject); gradleBuild.addProject(basicGradleProject); basicGradleProject.setParent(rootProject); rootProject.addChild(basicGradleProject); convertChildren(gradleBuild, basicGradleProject, childProject); } }
Example #25
Source File: GradleBuildAdapterProducer.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public <T> T produceModel(Class<T> type, ConsumerOperationParameters operationParameters) { if (type.getName().equals(GradleBuild.class.getName()) && !versionDetails.maySupportModel(type)) { GradleProject gradleProject = delegate.produceModel(GradleProject.class, operationParameters); final DefaultGradleBuild convert = new GradleBuildConverter().convert(gradleProject); return adapter.adapt(type, convert); } return delegate.produceModel(type, operationParameters); }
Example #26
Source File: ConnectionVersion4BackedConsumerConnection.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public <T> T produceModel(Class<T> modelType, ConsumerOperationParameters operationParameters) { if (modelType == GradleProject.class && !versionDetails.maySupportModel(GradleProject.class)) { //we broke compatibility around M9 wrt getting the tasks of a project (issue GRADLE-1875) //this patch enables getting gradle tasks for target gradle version pre M5 EclipseProjectVersion3 project = delegate.produceModel(EclipseProjectVersion3.class, operationParameters); return adapter.adapt(modelType, new GradleProjectConverter().convert(project)); } return delegate.produceModel(modelType, operationParameters); }
Example #27
Source File: ConnectionVersion4BackedConsumerConnection.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
@Override public boolean maySupportModel(Class<?> modelType) { return modelType.equals(HierarchicalEclipseProject.class) || modelType.equals(EclipseProject.class) || modelType.equals(IdeaProject.class) || modelType.equals(BasicIdeaProject.class) || modelType.equals(GradleProject.class) || modelType.equals(Void.class); }
Example #28
Source File: ModelMapping.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
private static void addModelVersions(Map<Class<?>, String> map) { map.put(HierarchicalEclipseProject.class, "1.0-milestone-3"); map.put(EclipseProject.class, "1.0-milestone-3"); map.put(IdeaProject.class, "1.0-milestone-5"); map.put(GradleProject.class, "1.0-milestone-5"); map.put(BasicIdeaProject.class, "1.0-milestone-5"); map.put(BuildEnvironment.class, "1.0-milestone-8"); map.put(ProjectOutcomes.class, "1.2"); map.put(Void.class, "1.0-milestone-3"); map.put(GradleBuild.class, "1.8"); }
Example #29
Source File: ModelMapping.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
static void addModelToProtocolMappings(Map<Class<?>, Class<?>> map) { map.put(HierarchicalEclipseProject.class, HierarchicalEclipseProjectVersion1.class); map.put(EclipseProject.class, EclipseProjectVersion3.class); map.put(IdeaProject.class, InternalIdeaProject.class); map.put(GradleProject.class, InternalGradleProject.class); map.put(BasicIdeaProject.class, InternalBasicIdeaProject.class); map.put(BuildEnvironment.class, InternalBuildEnvironment.class); map.put(ProjectOutcomes.class, InternalProjectOutcomes.class); map.put(Void.class, Void.class); }
Example #30
Source File: ModelMapping.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
static void addModelNameMappings(Map<Class<?>, String> map) { map.put(HierarchicalEclipseProject.class, "org.gradle.tooling.model.eclipse.HierarchicalEclipseProject"); map.put(EclipseProject.class, "org.gradle.tooling.model.eclipse.EclipseProject"); map.put(IdeaProject.class, "org.gradle.tooling.model.idea.IdeaProject"); map.put(GradleProject.class, "org.gradle.tooling.model.GradleProject"); map.put(BasicIdeaProject.class, "org.gradle.tooling.model.idea.BasicIdeaProject"); map.put(BuildEnvironment.class, "org.gradle.tooling.model.build.BuildEnvironment"); map.put(ProjectOutcomes.class, "org.gradle.tooling.model.outcomes.ProjectOutcomes"); map.put(Void.class, Void.class.getName()); }