gradle: debug logging for imported projects paths added

(cherry picked from commit f525ad3)
This commit is contained in:
Vladislav.Soroka
2015-01-15 11:44:02 +03:00
parent 2d4f833aa3
commit 9a7bfa228c
2 changed files with 25 additions and 6 deletions
@@ -26,6 +26,7 @@ import com.intellij.openapi.module.Module;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.util.Function;
import com.intellij.util.containers.ConcurrentFactoryMap;
import com.intellij.util.containers.ContainerUtil;
import gnu.trove.TObjectHashingStrategy;
@@ -122,7 +123,18 @@ public class ExternalProjectDataService implements ProjectDataService<ExternalPr
@Nullable
public ExternalProject getRootExternalProject(@NotNull ProjectSystemId systemId, @NotNull File projectRootDir) {
return myExternalRootProjects.get(Pair.create(systemId, projectRootDir));
ExternalProject externalProject = myExternalRootProjects.get(Pair.create(systemId, projectRootDir));
if (LOG.isDebugEnabled()) {
LOG.debug("Can not find data for project at: " + projectRootDir);
LOG.debug("Existing imported projects paths: " + ContainerUtil.map(myExternalRootProjects.entrySet(),
new Function<Map.Entry<Pair<ProjectSystemId, File>, ExternalProject>, Object>() {
@Override
public Object fun(Map.Entry<Pair<ProjectSystemId, File>, ExternalProject> entry) {
return Pair.create(entry.getKey(), entry.getValue().getProjectDir());
}
}));
}
return externalProject;
}
public void saveExternalProject(@NotNull ExternalProject externalProject) {
@@ -178,6 +178,8 @@ public class ExternalProjectSerializer {
output = new Output(new FileOutputStream(configurationFile));
myKryo.writeObject(output, externalProject);
LOG.debug("Data saved for imported project from: " + externalProjectPath);
}
catch (FileNotFoundException e) {
LOG.error(e);
@@ -189,13 +191,15 @@ public class ExternalProjectSerializer {
@Nullable
public ExternalProject load(@NotNull ProjectSystemId externalSystemId, File externalProjectPath) {
LOG.debug("Attempt to load project data from: " + externalProjectPath);
ExternalProject externalProject = null;
Input input = null;
try {
final File configurationFile = getProjectConfigurationFile(externalSystemId, externalProjectPath.getPath());
if (!configurationFile.isFile()) return null;
input = new Input(new FileInputStream(configurationFile));
return myKryo.readObject(input, DefaultExternalProject.class);
if (configurationFile.isFile()) {
input = new Input(new FileInputStream(configurationFile));
externalProject = myKryo.readObject(input, DefaultExternalProject.class);
}
}
catch (Exception e) {
LOG.error(e);
@@ -204,7 +208,10 @@ public class ExternalProjectSerializer {
StreamUtil.closeStream(input);
}
return null;
if (externalProject != null) {
LOG.debug("Loaded project: " + externalProject.getProjectDir());
}
return externalProject;
}
private static File getProjectConfigurationFile(ProjectSystemId externalSystemId, String externalProjectPath) {