Skip to content

Commit

Permalink
Change location of .tooling (#1655)
Browse files Browse the repository at this point in the history
Signed-off-by: Snjezana Peco <snjezana.peco@redhat.com>
  • Loading branch information
snjeza authored Feb 12, 2021
1 parent 0281f28 commit e663804
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
import java.io.File;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Optional;

import org.eclipse.buildship.core.BuildConfiguration;
Expand Down Expand Up @@ -92,9 +92,9 @@ public void update(IProject project, boolean force, IProgressMonitor monitor) th
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);
Map<String, EclipseProject> eclipseProjects = ((InternalGradleBuild) gradleBuild).getModelProvider().fetchModels(EclipseProject.class, FetchStrategy.LOAD_IF_NOT_CACHED, tokenSource, monitor);
File projectDirectory = project.getLocation().toFile();
for (EclipseProject eclipseProject : eclipseProjects) {
for (EclipseProject eclipseProject : eclipseProjects.values()) {
File eclipseProjectDirectory = eclipseProject.getProjectDirectory();
if (eclipseProjectDirectory.equals(projectDirectory)) {
return eclipseProject.getParent() == null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public ValidationResult checkWrapper(String baseDir) throws CoreException {
reader = new InputStreamReader(new FileInputStream(versionFile), Charsets.UTF_8);
String json = CharStreams.toString(reader);
Gson gson = new GsonBuilder().create();
TypeToken<List<Map<String, String>>> typeToken = new TypeToken<List<Map<String, String>>>() {
TypeToken<List<Map<String, String>>> typeToken = new TypeToken<>() {
};
List<Map<String, String>> versions = gson.fromJson(json, typeToken.getType());
//@formatter:off
Expand Down Expand Up @@ -253,14 +253,24 @@ private static String read(File file) {
}

private static File getVersionCacheFile() {
return new File(System.getProperty("user.home"), ".tooling/gradle/versions.json");
String xdgCache = getXdgCache();
return new File(xdgCache, "tooling/gradle/versions.json");
}

private static String getXdgCache() {
String xdgCache = System.getenv("XDG_CACHE_HOME");
if (xdgCache == null) {
xdgCache = System.getProperty("user.home") + "/.cache/";
}
return xdgCache;
}

public static File getSha256CacheFile() {
String checksumCache = System.getProperty("gradle.checksum.cacheDir");
File file;
if (checksumCache == null || checksumCache.isEmpty()) {
file = new File(System.getProperty("user.home"), ".tooling/gradle/checksums");
String xdgCache = getXdgCache();
file = new File(xdgCache, "tooling/gradle/checksums");
} else {
file = new File(checksumCache);
}
Expand Down
2 changes: 1 addition & 1 deletion org.eclipse.jdt.ls.target/org.eclipse.jdt.ls.tp.target
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</location>
<location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit">
<unit id="org.eclipse.buildship.feature.group" version="0.0.0"/>
<repository location="https://download.eclipse.org/buildship/updates/e415/snapshots/3.x/3.1.5.v20200806-2157-s/"/>
<repository location="https://download.eclipse.org/buildship/updates/e415/snapshots/3.x/3.1.5.v20210112-1646-s"/>
</location>
<location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit">
<unit id="org.eclipse.m2e.feature.feature.group" version="0.0.0"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@

import org.apache.commons.io.FileUtils;
import org.codehaus.plexus.util.StringUtils;
import org.eclipse.buildship.core.internal.CorePlugin;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
Expand Down Expand Up @@ -235,6 +236,7 @@ public void run(IProgressMonitor monitor) throws CoreException {

protected void waitForBackgroundJobs() throws Exception {
JobHelpers.waitForJobsToComplete(monitor);
Job.getJobManager().join(CorePlugin.GRADLE_JOB_FAMILY, new NullProgressMonitor());
}

protected File getSourceProjectDirectory() {
Expand All @@ -256,7 +258,7 @@ public void cleanUp() throws Exception {
WorkspaceHelper.deleteAllProjects();
FileUtils.forceDelete(getWorkingProjectDirectory());
Job.getJobManager().setProgressProvider(null);
JobHelpers.waitForJobsToComplete();
waitForBackgroundJobs();
}

protected void assertIsJavaProject(IProject project) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -488,8 +488,7 @@ public void testSubprojects() throws Exception {
projectsManager.updateProject(root, true);
projectsManager.updateProject(project1, true);
projectsManager.updateProject(project2, true);
JobHelpers.waitForJobsToComplete();
Job.getJobManager().join(CorePlugin.GRADLE_JOB_FAMILY, new NullProgressMonitor());
waitForBackgroundJobs();
ProjectConfiguration configuration = getProjectConfiguration(root);
// check the children .settings/org.eclipse.buildship.core.prefs
assertTrue(configuration.getBuildConfiguration().isOverrideWorkspaceSettings());
Expand Down Expand Up @@ -535,7 +534,7 @@ public void testSettingsGradle() throws Exception {
IFile build = project.getFile("/build.gradle");
build.setContents(contents, true, false, null);
projectsManager.updateProject(project, false);
JobHelpers.waitForJobsToComplete();
waitForBackgroundJobs();
type = javaProject.findType("org.apache.commons.lang3.StringUtils");
assertNotNull(type);
}
Expand Down

0 comments on commit e663804

Please sign in to comment.