{"action":"created","comment":{"url":"https://api.github.com/repos/ignatov/intellij-erlang/pulls/comments/37181616","id":37181616,"diff_hunk":"@@ -0,0 +1,270 @@\n+/*\n+ * Copyright 2012-2015 Sergey Ignatov\n+ *\n+ * Licensed under the Apache License, Version 2.0 (the \"License\");\n+ * you may not use this file except in compliance with the License.\n+ * You may obtain a copy of the License at\n+ *\n+ * http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing, software\n+ * distributed under the License is distributed on an \"AS IS\" BASIS,\n+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+ * See the License for the specific language governing permissions and\n+ * limitations under the License.\n+ */\n+\n+package org.intellij.erlang.jps.builder;\n+\n+import com.intellij.openapi.util.JDOMUtil;\n+import com.intellij.util.Function;\n+import com.intellij.util.SystemProperties;\n+import com.intellij.util.containers.ContainerUtil;\n+import com.intellij.util.graph.GraphGenerator;\n+import com.intellij.util.xmlb.SkipDefaultValuesSerializationFilters;\n+import com.intellij.util.xmlb.XmlSerializationException;\n+import com.intellij.util.xmlb.XmlSerializer;\n+import org.jdom.Document;\n+import org.jdom.JDOMException;\n+import org.jetbrains.annotations.NotNull;\n+import org.jetbrains.annotations.Nullable;\n+import org.jetbrains.jps.builders.BuildOutputConsumer;\n+import org.jetbrains.jps.builders.DirtyFilesHolder;\n+import org.jetbrains.jps.incremental.CompileContext;\n+import org.jetbrains.jps.incremental.ProjectBuildException;\n+import org.jetbrains.jps.incremental.TargetBuilder;\n+import org.jetbrains.jps.incremental.messages.BuildMessage;\n+import org.jetbrains.jps.incremental.messages.CompilerMessage;\n+import org.jetbrains.jps.model.JpsProject;\n+import org.jetbrains.jps.model.java.JavaSourceRootProperties;\n+import org.jetbrains.jps.model.java.JavaSourceRootType;\n+import org.jetbrains.jps.model.module.JpsModule;\n+import org.jetbrains.jps.model.module.JpsTypedModuleSourceRoot;\n+\n+import java.io.File;\n+import java.io.IOException;\n+import java.util.*;\n+\n+public class ErlangPrepareDependenciesBuilder extends TargetBuilder<ErlangSourceRootDescriptor, ErlangPrepareDependenciesTarget> {\n+  public static final String DEPENDENCIES_TREE_FILE_PATH = \"erlang-builder/deps-tree.xml\";\n+  private static final String NAME = \"Prepare dependence\";\n+\n+  public ErlangPrepareDependenciesBuilder() {\n+    super(Collections.singletonList(ErlangPrepareDependenciesTargetType.INSTANCE));\n+  }\n+\n+  @Override\n+  public void build(@NotNull ErlangPrepareDependenciesTarget target,\n+                    @NotNull DirtyFilesHolder<ErlangSourceRootDescriptor, ErlangPrepareDependenciesTarget> holder,\n+                    @NotNull BuildOutputConsumer outputConsumer,\n+                    @NotNull CompileContext context) throws ProjectBuildException, IOException {\n+    ErlangDependencyTree dependencyTree = loadDependencyTree(context);\n+    if (dependencyTree == null) {\n+      addPrepareDependenciesFailedMessage(context);\n+      return;\n+    }\n+\n+    List<String> dirtyErlangFilePaths = new DirtyFileProcessor<String, ErlangPrepareDependenciesTarget>() {\n+      @Nullable\n+      @Override\n+      protected String getDirtyElement(@NotNull ErlangPrepareDependenciesTarget target,\n+                                       @NotNull File file,\n+                                       @NotNull ErlangSourceRootDescriptor root) throws IOException {\n+        return isSourceOrHeader(file) ? file.getAbsolutePath() : null;\n+      }\n+    }.collectDirtyElements(holder);\n+    prepareDependencies(target.getProject(), context, dependencyTree, dirtyErlangFilePaths);\n+  }\n+\n+  @NotNull\n+  @Override\n+  public String getPresentableName() {\n+    return NAME;\n+  }\n+\n+  @Nullable\n+  private static ErlangDependencyTree loadDependencyTree(@NotNull CompileContext context) {\n+    File dataStorageRoot = context.getProjectDescriptor().dataManager.getDataPaths().getDataStorageRoot();\n+    File depsTreeFile = new File(dataStorageRoot, DEPENDENCIES_TREE_FILE_PATH);\n+    if (!depsTreeFile.exists()) return null;\n+    ErlangDependencyTree erlangDependencyTree;\n+    try {\n+      Document document = JDOMUtil.loadDocument(depsTreeFile);\n+      erlangDependencyTree = XmlSerializer.deserialize(document, ErlangDependencyTree.class);\n+    }\n+    catch (XmlSerializationException e) {\n+      return null;\n+    }\n+    catch (JDOMException e) {\n+      return null;\n+    }\n+    catch (IOException e) {\n+      return null;\n+    }\n+    return erlangDependencyTree;","path":"jps-plugin/src/org/intellij/erlang/jps/builder/ErlangPrepareDependenciesBuilder.java","position":104,"original_position":104,"commit_id":"bf9014daef7e0c1e21b8354eff6e7ddd1ed5e04e","original_commit_id":"bf9014daef7e0c1e21b8354eff6e7ddd1ed5e04e","user":{"login":"deadok22","id":1259620,"avatar_url":"https://avatars.githubusercontent.com/u/1259620?v=3","gravatar_id":"","url":"https://api.github.com/users/deadok22","html_url":"https://github.com/deadok22","followers_url":"https://api.github.com/users/deadok22/followers","following_url":"https://api.github.com/users/deadok22/following{/other_user}","gists_url":"https://api.github.com/users/deadok22/gists{/gist_id}","starred_url":"https://api.github.com/users/deadok22/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/deadok22/subscriptions","organizations_url":"https://api.github.com/users/deadok22/orgs","repos_url":"https://api.github.com/users/deadok22/repos","events_url":"https://api.github.com/users/deadok22/events{/privacy}","received_events_url":"https://api.github.com/users/deadok22/received_events","type":"User","site_admin":false},"body":"You've copied this code from ErlangBuilder. Extract an utility method instead.","created_at":"2015-08-17T12:16:55Z","updated_at":"2015-08-17T12:16:55Z","html_url":"https://github.com/ignatov/intellij-erlang/pull/668#discussion_r37181616","pull_request_url":"https://api.github.com/repos/ignatov/intellij-erlang/pulls/668","_links":{"self":{"href":"https://api.github.com/repos/ignatov/intellij-erlang/pulls/comments/37181616"},"html":{"href":"https://github.com/ignatov/intellij-erlang/pull/668#discussion_r37181616"},"pull_request":{"href":"https://api.github.com/repos/ignatov/intellij-erlang/pulls/668"}}},"pull_request":{"url":"https://api.github.com/repos/ignatov/intellij-erlang/pulls/668","id":42354671,"html_url":"https://github.com/ignatov/intellij-erlang/pull/668","diff_url":"https://github.com/ignatov/intellij-erlang/pull/668.diff","patch_url":"https://github.com/ignatov/intellij-erlang/pull/668.patch","issue_url":"https://api.github.com/repos/ignatov/intellij-erlang/issues/668","number":668,"state":"open","locked":false,"title":"#657  Fix problem with cross module dependencies.","user":{"login":"avesloguzova","id":5417013,"avatar_url":"https://avatars.githubusercontent.com/u/5417013?v=3","gravatar_id":"","url":"https://api.github.com/users/avesloguzova","html_url":"https://github.com/avesloguzova","followers_url":"https://api.github.com/users/avesloguzova/followers","following_url":"https://api.github.com/users/avesloguzova/following{/other_user}","gists_url":"https://api.github.com/users/avesloguzova/gists{/gist_id}","starred_url":"https://api.github.com/users/avesloguzova/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/avesloguzova/subscriptions","organizations_url":"https://api.github.com/users/avesloguzova/orgs","repos_url":"https://api.github.com/users/avesloguzova/repos","events_url":"https://api.github.com/users/avesloguzova/events{/privacy}","received_events_url":"https://api.github.com/users/avesloguzova/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-08-13T14:11:23Z","updated_at":"2015-08-17T12:16:55Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8a0112de4ceaa25bbea4a8d5752ec36c00e6c589","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ignatov/intellij-erlang/pulls/668/commits","review_comments_url":"https://api.github.com/repos/ignatov/intellij-erlang/pulls/668/comments","review_comment_url":"https://api.github.com/repos/ignatov/intellij-erlang/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ignatov/intellij-erlang/issues/668/comments","statuses_url":"https://api.github.com/repos/ignatov/intellij-erlang/statuses/bf9014daef7e0c1e21b8354eff6e7ddd1ed5e04e","head":{"label":"avesloguzova:657","ref":"657","sha":"bf9014daef7e0c1e21b8354eff6e7ddd1ed5e04e","user":{"login":"avesloguzova","id":5417013,"avatar_url":"https://avatars.githubusercontent.com/u/5417013?v=3","gravatar_id":"","url":"https://api.github.com/users/avesloguzova","html_url":"https://github.com/avesloguzova","followers_url":"https://api.github.com/users/avesloguzova/followers","following_url":"https://api.github.com/users/avesloguzova/following{/other_user}","gists_url":"https://api.github.com/users/avesloguzova/gists{/gist_id}","starred_url":"https://api.github.com/users/avesloguzova/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/avesloguzova/subscriptions","organizations_url":"https://api.github.com/users/avesloguzova/orgs","repos_url":"https://api.github.com/users/avesloguzova/repos","events_url":"https://api.github.com/users/avesloguzova/events{/privacy}","received_events_url":"https://api.github.com/users/avesloguzova/received_events","type":"User","site_admin":false},"repo":{"id":38375394,"name":"intellij-erlang","full_name":"avesloguzova/intellij-erlang","owner":{"login":"avesloguzova","id":5417013,"avatar_url":"https://avatars.githubusercontent.com/u/5417013?v=3","gravatar_id":"","url":"https://api.github.com/users/avesloguzova","html_url":"https://github.com/avesloguzova","followers_url":"https://api.github.com/users/avesloguzova/followers","following_url":"https://api.github.com/users/avesloguzova/following{/other_user}","gists_url":"https://api.github.com/users/avesloguzova/gists{/gist_id}","starred_url":"https://api.github.com/users/avesloguzova/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/avesloguzova/subscriptions","organizations_url":"https://api.github.com/users/avesloguzova/orgs","repos_url":"https://api.github.com/users/avesloguzova/repos","events_url":"https://api.github.com/users/avesloguzova/events{/privacy}","received_events_url":"https://api.github.com/users/avesloguzova/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/avesloguzova/intellij-erlang","description":"Erlang IDE (IntelliJ-based)","fork":true,"url":"https://api.github.com/repos/avesloguzova/intellij-erlang","forks_url":"https://api.github.com/repos/avesloguzova/intellij-erlang/forks","keys_url":"https://api.github.com/repos/avesloguzova/intellij-erlang/keys{/key_id}","collaborators_url":"https://api.github.com/repos/avesloguzova/intellij-erlang/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/avesloguzova/intellij-erlang/teams","hooks_url":"https://api.github.com/repos/avesloguzova/intellij-erlang/hooks","issue_events_url":"https://api.github.com/repos/avesloguzova/intellij-erlang/issues/events{/number}","events_url":"https://api.github.com/repos/avesloguzova/intellij-erlang/events","assignees_url":"https://api.github.com/repos/avesloguzova/intellij-erlang/assignees{/user}","branches_url":"https://api.github.com/repos/avesloguzova/intellij-erlang/branches{/branch}","tags_url":"https://api.github.com/repos/avesloguzova/intellij-erlang/tags","blobs_url":"https://api.github.com/repos/avesloguzova/intellij-erlang/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/avesloguzova/intellij-erlang/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/avesloguzova/intellij-erlang/git/refs{/sha}","trees_url":"https://api.github.com/repos/avesloguzova/intellij-erlang/git/trees{/sha}","statuses_url":"https://api.github.com/repos/avesloguzova/intellij-erlang/statuses/{sha}","languages_url":"https://api.github.com/repos/avesloguzova/intellij-erlang/languages","stargazers_url":"https://api.github.com/repos/avesloguzova/intellij-erlang/stargazers","contributors_url":"https://api.github.com/repos/avesloguzova/intellij-erlang/contributors","subscribers_url":"https://api.github.com/repos/avesloguzova/intellij-erlang/subscribers","subscription_url":"https://api.github.com/repos/avesloguzova/intellij-erlang/subscription","commits_url":"https://api.github.com/repos/avesloguzova/intellij-erlang/commits{/sha}","git_commits_url":"https://api.github.com/repos/avesloguzova/intellij-erlang/git/commits{/sha}","comments_url":"https://api.github.com/repos/avesloguzova/intellij-erlang/comments{/number}","issue_comment_url":"https://api.github.com/repos/avesloguzova/intellij-erlang/issues/comments{/number}","contents_url":"https://api.github.com/repos/avesloguzova/intellij-erlang/contents/{+path}","compare_url":"https://api.github.com/repos/avesloguzova/intellij-erlang/compare/{base}...{head}","merges_url":"https://api.github.com/repos/avesloguzova/intellij-erlang/merges","archive_url":"https://api.github.com/repos/avesloguzova/intellij-erlang/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/avesloguzova/intellij-erlang/downloads","issues_url":"https://api.github.com/repos/avesloguzova/intellij-erlang/issues{/number}","pulls_url":"https://api.github.com/repos/avesloguzova/intellij-erlang/pulls{/number}","milestones_url":"https://api.github.com/repos/avesloguzova/intellij-erlang/milestones{/number}","notifications_url":"https://api.github.com/repos/avesloguzova/intellij-erlang/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/avesloguzova/intellij-erlang/labels{/name}","releases_url":"https://api.github.com/repos/avesloguzova/intellij-erlang/releases{/id}","created_at":"2015-07-01T14:22:27Z","updated_at":"2015-07-01T14:22:30Z","pushed_at":"2015-08-17T09:56:11Z","git_url":"git://github.com/avesloguzova/intellij-erlang.git","ssh_url":"git@github.com:avesloguzova/intellij-erlang.git","clone_url":"https://github.com/avesloguzova/intellij-erlang.git","svn_url":"https://github.com/avesloguzova/intellij-erlang","homepage":"https://www.jetbrains.com/idea/features/erlang.html","size":69304,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"ignatov:master","ref":"master","sha":"7dbf2d6e1bfc318563da385bd646dd08a8b8f6cf","user":{"login":"ignatov","id":426890,"avatar_url":"https://avatars.githubusercontent.com/u/426890?v=3","gravatar_id":"","url":"https://api.github.com/users/ignatov","html_url":"https://github.com/ignatov","followers_url":"https://api.github.com/users/ignatov/followers","following_url":"https://api.github.com/users/ignatov/following{/other_user}","gists_url":"https://api.github.com/users/ignatov/gists{/gist_id}","starred_url":"https://api.github.com/users/ignatov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ignatov/subscriptions","organizations_url":"https://api.github.com/users/ignatov/orgs","repos_url":"https://api.github.com/users/ignatov/repos","events_url":"https://api.github.com/users/ignatov/events{/privacy}","received_events_url":"https://api.github.com/users/ignatov/received_events","type":"User","site_admin":false},"repo":{"id":5168907,"name":"intellij-erlang","full_name":"ignatov/intellij-erlang","owner":{"login":"ignatov","id":426890,"avatar_url":"https://avatars.githubusercontent.com/u/426890?v=3","gravatar_id":"","url":"https://api.github.com/users/ignatov","html_url":"https://github.com/ignatov","followers_url":"https://api.github.com/users/ignatov/followers","following_url":"https://api.github.com/users/ignatov/following{/other_user}","gists_url":"https://api.github.com/users/ignatov/gists{/gist_id}","starred_url":"https://api.github.com/users/ignatov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ignatov/subscriptions","organizations_url":"https://api.github.com/users/ignatov/orgs","repos_url":"https://api.github.com/users/ignatov/repos","events_url":"https://api.github.com/users/ignatov/events{/privacy}","received_events_url":"https://api.github.com/users/ignatov/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ignatov/intellij-erlang","description":"Erlang IDE (IntelliJ-based)","fork":false,"url":"https://api.github.com/repos/ignatov/intellij-erlang","forks_url":"https://api.github.com/repos/ignatov/intellij-erlang/forks","keys_url":"https://api.github.com/repos/ignatov/intellij-erlang/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ignatov/intellij-erlang/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ignatov/intellij-erlang/teams","hooks_url":"https://api.github.com/repos/ignatov/intellij-erlang/hooks","issue_events_url":"https://api.github.com/repos/ignatov/intellij-erlang/issues/events{/number}","events_url":"https://api.github.com/repos/ignatov/intellij-erlang/events","assignees_url":"https://api.github.com/repos/ignatov/intellij-erlang/assignees{/user}","branches_url":"https://api.github.com/repos/ignatov/intellij-erlang/branches{/branch}","tags_url":"https://api.github.com/repos/ignatov/intellij-erlang/tags","blobs_url":"https://api.github.com/repos/ignatov/intellij-erlang/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ignatov/intellij-erlang/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ignatov/intellij-erlang/git/refs{/sha}","trees_url":"https://api.github.com/repos/ignatov/intellij-erlang/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ignatov/intellij-erlang/statuses/{sha}","languages_url":"https://api.github.com/repos/ignatov/intellij-erlang/languages","stargazers_url":"https://api.github.com/repos/ignatov/intellij-erlang/stargazers","contributors_url":"https://api.github.com/repos/ignatov/intellij-erlang/contributors","subscribers_url":"https://api.github.com/repos/ignatov/intellij-erlang/subscribers","subscription_url":"https://api.github.com/repos/ignatov/intellij-erlang/subscription","commits_url":"https://api.github.com/repos/ignatov/intellij-erlang/commits{/sha}","git_commits_url":"https://api.github.com/repos/ignatov/intellij-erlang/git/commits{/sha}","comments_url":"https://api.github.com/repos/ignatov/intellij-erlang/comments{/number}","issue_comment_url":"https://api.github.com/repos/ignatov/intellij-erlang/issues/comments{/number}","contents_url":"https://api.github.com/repos/ignatov/intellij-erlang/contents/{+path}","compare_url":"https://api.github.com/repos/ignatov/intellij-erlang/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ignatov/intellij-erlang/merges","archive_url":"https://api.github.com/repos/ignatov/intellij-erlang/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ignatov/intellij-erlang/downloads","issues_url":"https://api.github.com/repos/ignatov/intellij-erlang/issues{/number}","pulls_url":"https://api.github.com/repos/ignatov/intellij-erlang/pulls{/number}","milestones_url":"https://api.github.com/repos/ignatov/intellij-erlang/milestones{/number}","notifications_url":"https://api.github.com/repos/ignatov/intellij-erlang/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ignatov/intellij-erlang/labels{/name}","releases_url":"https://api.github.com/repos/ignatov/intellij-erlang/releases{/id}","created_at":"2012-07-24T17:41:30Z","updated_at":"2015-08-06T03:10:22Z","pushed_at":"2015-08-17T12:12:33Z","git_url":"git://github.com/ignatov/intellij-erlang.git","ssh_url":"git@github.com:ignatov/intellij-erlang.git","clone_url":"https://github.com/ignatov/intellij-erlang.git","svn_url":"https://github.com/ignatov/intellij-erlang","homepage":"https://www.jetbrains.com/idea/features/erlang.html","size":74350,"stargazers_count":395,"watchers_count":395,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":44,"mirror_url":null,"open_issues_count":122,"forks":44,"open_issues":122,"watchers":395,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ignatov/intellij-erlang/pulls/668"},"html":{"href":"https://github.com/ignatov/intellij-erlang/pull/668"},"issue":{"href":"https://api.github.com/repos/ignatov/intellij-erlang/issues/668"},"comments":{"href":"https://api.github.com/repos/ignatov/intellij-erlang/issues/668/comments"},"review_comments":{"href":"https://api.github.com/repos/ignatov/intellij-erlang/pulls/668/comments"},"review_comment":{"href":"https://api.github.com/repos/ignatov/intellij-erlang/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ignatov/intellij-erlang/pulls/668/commits"},"statuses":{"href":"https://api.github.com/repos/ignatov/intellij-erlang/statuses/bf9014daef7e0c1e21b8354eff6e7ddd1ed5e04e"}}}}