org.gradle.tooling.model.eclipse.EclipseProject Java Examples

The following examples show how to use org.gradle.tooling.model.eclipse.EclipseProject. 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: GradleBuildFileFromConnector.java    From quarkus with Apache License 2.0 6 votes vote down vote up
@Override
public List<Dependency> getDependencies() throws IOException {
    if (dependencies == null) {
        EclipseProject eclipseProject = null;
        if (getBuildContent() != null) {
            try {
                ProjectConnection connection = GradleConnector.newConnector()
                        .forProjectDirectory(getProjectDirPath().toFile())
                        .connect();
                eclipseProject = connection.getModel(EclipseProject.class);
            } catch (BuildException e) {
                // ignore this error.
                e.printStackTrace();
            }
        }
        if (eclipseProject != null) {
            dependencies = eclipseProject.getClasspath().stream().map(this::gradleModuleVersionToDependency)
                    .filter(Objects::nonNull)
                    .collect(Collectors.toList());
        } else {
            dependencies = Collections.emptyList();
        }
        dependencies = Collections.unmodifiableList(dependencies);
    }
    return dependencies;
}
 
Example #2
Source File: ModelMapping.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 #3
Source File: BuildActionRunnerBackedConsumerConnection.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@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 #4
Source File: InternalConnectionBackedConsumerConnection.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@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 #5
Source File: ConnectionVersion4BackedConsumerConnection.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@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 #6
Source File: ModelMapping.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 #7
Source File: ModelMapping.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 #8
Source File: ModelMapping.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 #9
Source File: BuildActionRunnerBackedConsumerConnection.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@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 #10
Source File: InternalConnectionBackedConsumerConnection.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@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 #11
Source File: ModelMapping.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 #12
Source File: ModelMapping.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 #13
Source File: ModelMapping.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 #14
Source File: GradleBuildSupport.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
private boolean isRoot(IProject project, GradleBuild gradleBuild, IProgressMonitor monitor) {
	if (gradleBuild instanceof InternalGradleBuild) {
		CancellationTokenSource tokenSource = GradleConnector.newCancellationTokenSource();
		Collection<EclipseProject> eclipseProjects = ((InternalGradleBuild) gradleBuild).getModelProvider().fetchModels(EclipseProject.class, FetchStrategy.LOAD_IF_NOT_CACHED, tokenSource, monitor);
		for (EclipseProject eclipseProject : eclipseProjects) {
			File eclipseProjectDirectory = eclipseProject.getProjectDirectory();
			File projectDirectory = project.getLocation().toFile();
			if (eclipseProjectDirectory.equals(projectDirectory)) {
				return eclipseProject.getParent() == null;
			}
		}
	}
	return false;
}
 
Example #15
Source File: GradleProjectSettingsConfigurator.java    From spring-javaformat with Apache License 2.0 5 votes vote down vote up
private Set<File> getSearchFolders(Collection<EclipseProject> projects) {
	Set<File> searchFolders = new LinkedHashSet<>();
	for (EclipseProject project : projects) {
		while (project != null) {
			searchFolders.add(project.getProjectDirectory());
			project = project.getParent();
		}
	}
	return searchFolders;
}
 
Example #16
Source File: GradleProjectSettingsConfigurator.java    From spring-javaformat with Apache License 2.0 5 votes vote down vote up
private EclipseProject findProjectByName(Iterable<? extends EclipseProject> candidates, String name) {
	for (EclipseProject candidate : candidates) {
		if (name.equals(candidate.getName())) {
			return candidate;
		}
		EclipseProject childResult = findProjectByName(candidate.getChildren(), name);
		if (childResult != null) {
			return childResult;
		}
	}
	return null;
}
 
Example #17
Source File: ModelMapping.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 #18
Source File: ModelMapping.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 #19
Source File: InternalConnectionBackedConsumerConnection.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@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 pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@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: ModelMapping.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 #22
Source File: ModelMapping.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 #23
Source File: ModelMapping.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 #24
Source File: ConnectionVersion4BackedConsumerConnection.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@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 #25
Source File: InternalConnectionBackedConsumerConnection.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@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 #26
Source File: BuildActionRunnerBackedConsumerConnection.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@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 #27
Source File: GradleProjectSettingsConfigurator.java    From spring-javaformat with Apache License 2.0 5 votes vote down vote up
private void configureProject(IProject project, IProgressMonitor monitor) throws CoreException, IOException {
	InternalGradleWorkspace workspace = CorePlugin.internalGradleWorkspace();
	Optional<GradleBuild> build = workspace.getBuild(project);
	if (build.isPresent()) {
		ModelProvider modelProvider = ((InternalGradleBuild) build.get()).getModelProvider();
		Collection<EclipseProject> rootProjects = modelProvider.fetchModels(EclipseProject.class,
				FetchStrategy.FORCE_RELOAD, this.tokenSource, monitor);
		EclipseProject eclipseProject = findProjectByName(rootProjects, project.getName());
		if (hasSpringFormatPlugin(eclipseProject)) {
			ProjectSettingsFilesLocator locator = new ProjectSettingsFilesLocator(getSearchFolders(rootProjects));
			locator.locateSettingsFiles().applyToProject(project, monitor);
		}
	}
}
 
Example #28
Source File: GradleProjectSettingsConfigurator.java    From spring-javaformat with Apache License 2.0 5 votes vote down vote up
private boolean hasSpringFormatPlugin(EclipseProject eclipseProject) {
	if (eclipseProject != null) {
		for (GradleTask task : eclipseProject.getGradleProject().getTasks()) {
			if (isSpringFormatPlugin(task)) {
				return true;
			}
		}
	}
	return false;
}
 
Example #29
Source File: ConnectionVersion4BackedConsumerConnection.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public boolean maySupportModel(Class<?> modelType) {
    return modelType.equals(HierarchicalEclipseProject.class) || modelType.equals(EclipseProjectVersion3.class) || modelType.equals(EclipseProject.class) || modelType.equals(Void.class);
}
 
Example #30
Source File: ConnectionVersion4BackedConsumerConnection.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public boolean maySupportModel(Class<?> modelType) {
    return modelType.equals(HierarchicalEclipseProject.class) || modelType.equals(EclipseProjectVersion3.class) || modelType.equals(EclipseProject.class) || modelType.equals(Void.class);
}