{"action":"created","comment":{"url":"https://api.github.com/repos/realm/realm-java/pulls/comments/40058025","id":40058025,"diff_hunk":"@@ -89,18 +104,75 @@ task checkProperties(group: 'check', description: 'Check the user provided gradl\n     }\n }\n \n-// TODO: Split this task into smaller subtasks\n+ext.coreArchiveFile = project.file(\"../core-android-${project.coreVersion}.tar.gz\")\n+ext.coreDir = new File(buildDir, \"core-${project.coreVersion}\")\n+\n+def coreDownloaded = false\n+\n task downloadCore(group: 'build setup', description: 'Download the latest version of realm core', dependsOn: checkProperties) {\n-    outputs.dir \"../core-${project.coreVersion}\"\n+    outputs.upToDateWhen {\n+        if (project.forceDownloadCore || !project.coreArchiveFile.exists()) {\n+            return false\n+        }\n+        if (!isHashCheckingEnabled()) {\n+            println 'skipped hash checking(empty \\'coreSha256Hash\\').'\n+            return true\n+        }\n+\n+        MessageDigest sha = MessageDigest.getInstance(\"SHA-256\");\n+        Formatter hexHash = new Formatter()\n+        sha.digest(project.coreArchiveFile.bytes).each { b -> hexHash.format('%02x', b) }\n+        return project.coreSha256Hash.equals(hexHash.toString())\n+    }\n+\n     doLast {\n+        if (project.forceDownloadCore) {\n+            println 'forceDownloadCore is true.'\n+        }\n         download {\n             src \"http://static.realm.io/downloads/core/realm-core-android-${project.coreVersion}.tar.gz\"\n-            dest new File(buildDir, \"core-android-${project.coreVersion}.tar.gz\")\n-            onlyIfNewer true\n+            dest project.coreArchiveFile\n+            onlyIfNewer false\n+        }\n+        coreDownloaded = true\n+        if (!isHashCheckingEnabled()) {\n+            println 'skipped hash checking(empty \\'coreSha256Hash\\').'\n+        }\n+    }\n+}\n+\n+task downloadAndVerifyCore(type: de.undercouch.gradle.tasks.download.Verify, dependsOn: downloadCore) {\n+    src       project.coreArchiveFile\n+    algorithm 'SHA-256'\n+    checksum  isHashCheckingEnabled() ? project.coreSha256Hash : ''\n+}\n+\n+task deployCore(group: 'build setup', description: 'Deploy the latest version of realm core') {\n+    if (isHashCheckingEnabled()) {","path":"realm-jni/build.gradle","position":98,"original_position":98,"commit_id":"654a202d6fbee55c12fd7256546c4d299b634be6","original_commit_id":"654a202d6fbee55c12fd7256546c4d299b634be6","user":{"login":"cmelchior","id":406066,"avatar_url":"https://avatars.githubusercontent.com/u/406066?v=3","gravatar_id":"","url":"https://api.github.com/users/cmelchior","html_url":"https://github.com/cmelchior","followers_url":"https://api.github.com/users/cmelchior/followers","following_url":"https://api.github.com/users/cmelchior/following{/other_user}","gists_url":"https://api.github.com/users/cmelchior/gists{/gist_id}","starred_url":"https://api.github.com/users/cmelchior/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cmelchior/subscriptions","organizations_url":"https://api.github.com/users/cmelchior/orgs","repos_url":"https://api.github.com/users/cmelchior/repos","events_url":"https://api.github.com/users/cmelchior/events{/privacy}","received_events_url":"https://api.github.com/users/cmelchior/received_events","type":"User","site_admin":false},"body":"Minor thing: It would feel more encapsulated if this if statement was part of just a `downloadCore` task, i.e. merge `downloadCore` and `downloadAndVerifyCore` instead of having having the hash being referenced across 3 functions.","created_at":"2015-09-22T07:15:40Z","updated_at":"2015-09-22T07:15:40Z","html_url":"https://github.com/realm/realm-java/pull/1488#discussion_r40058025","pull_request_url":"https://api.github.com/repos/realm/realm-java/pulls/1488","_links":{"self":{"href":"https://api.github.com/repos/realm/realm-java/pulls/comments/40058025"},"html":{"href":"https://github.com/realm/realm-java/pull/1488#discussion_r40058025"},"pull_request":{"href":"https://api.github.com/repos/realm/realm-java/pulls/1488"}}},"pull_request":{"url":"https://api.github.com/repos/realm/realm-java/pulls/1488","id":45590666,"html_url":"https://github.com/realm/realm-java/pull/1488","diff_url":"https://github.com/realm/realm-java/pull/1488.diff","patch_url":"https://github.com/realm/realm-java/pull/1488.patch","issue_url":"https://api.github.com/repos/realm/realm-java/issues/1488","number":1488,"state":"open","locked":false,"title":"moved core files into realm-jni/build/ and keep archive file of core under root project. related to #1479","user":{"login":"zaki50","id":406660,"avatar_url":"https://avatars.githubusercontent.com/u/406660?v=3","gravatar_id":"","url":"https://api.github.com/users/zaki50","html_url":"https://github.com/zaki50","followers_url":"https://api.github.com/users/zaki50/followers","following_url":"https://api.github.com/users/zaki50/following{/other_user}","gists_url":"https://api.github.com/users/zaki50/gists{/gist_id}","starred_url":"https://api.github.com/users/zaki50/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zaki50/subscriptions","organizations_url":"https://api.github.com/users/zaki50/orgs","repos_url":"https://api.github.com/users/zaki50/repos","events_url":"https://api.github.com/users/zaki50/events{/privacy}","received_events_url":"https://api.github.com/users/zaki50/received_events","type":"User","site_admin":false},"body":"And introduced SHA-256 hash checking to archive file.\nThe archive file is downloaded only when specified hash differs from local archive.\n\nWhen new core is comming, please update 'ext.coreSha256Hash' in realm-jni/build.gradle in addition to 'ext.coreVersion'.","created_at":"2015-09-21T19:43:46Z","updated_at":"2015-09-22T07:15:40Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a11495110c6aa4c3d884d0bc55265895aee93762","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/realm/realm-java/pulls/1488/commits","review_comments_url":"https://api.github.com/repos/realm/realm-java/pulls/1488/comments","review_comment_url":"https://api.github.com/repos/realm/realm-java/pulls/comments{/number}","comments_url":"https://api.github.com/repos/realm/realm-java/issues/1488/comments","statuses_url":"https://api.github.com/repos/realm/realm-java/statuses/654a202d6fbee55c12fd7256546c4d299b634be6","head":{"label":"zaki50:keep_core_archive_and_introduce_hash_checking","ref":"keep_core_archive_and_introduce_hash_checking","sha":"654a202d6fbee55c12fd7256546c4d299b634be6","user":{"login":"zaki50","id":406660,"avatar_url":"https://avatars.githubusercontent.com/u/406660?v=3","gravatar_id":"","url":"https://api.github.com/users/zaki50","html_url":"https://github.com/zaki50","followers_url":"https://api.github.com/users/zaki50/followers","following_url":"https://api.github.com/users/zaki50/following{/other_user}","gists_url":"https://api.github.com/users/zaki50/gists{/gist_id}","starred_url":"https://api.github.com/users/zaki50/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zaki50/subscriptions","organizations_url":"https://api.github.com/users/zaki50/orgs","repos_url":"https://api.github.com/users/zaki50/repos","events_url":"https://api.github.com/users/zaki50/events{/privacy}","received_events_url":"https://api.github.com/users/zaki50/received_events","type":"User","site_admin":false},"repo":{"id":35264603,"name":"realm-java","full_name":"zaki50/realm-java","owner":{"login":"zaki50","id":406660,"avatar_url":"https://avatars.githubusercontent.com/u/406660?v=3","gravatar_id":"","url":"https://api.github.com/users/zaki50","html_url":"https://github.com/zaki50","followers_url":"https://api.github.com/users/zaki50/followers","following_url":"https://api.github.com/users/zaki50/following{/other_user}","gists_url":"https://api.github.com/users/zaki50/gists{/gist_id}","starred_url":"https://api.github.com/users/zaki50/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zaki50/subscriptions","organizations_url":"https://api.github.com/users/zaki50/orgs","repos_url":"https://api.github.com/users/zaki50/repos","events_url":"https://api.github.com/users/zaki50/events{/privacy}","received_events_url":"https://api.github.com/users/zaki50/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/zaki50/realm-java","description":"Realm is a mobile database: a replacement for SQLite & ORMs","fork":true,"url":"https://api.github.com/repos/zaki50/realm-java","forks_url":"https://api.github.com/repos/zaki50/realm-java/forks","keys_url":"https://api.github.com/repos/zaki50/realm-java/keys{/key_id}","collaborators_url":"https://api.github.com/repos/zaki50/realm-java/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/zaki50/realm-java/teams","hooks_url":"https://api.github.com/repos/zaki50/realm-java/hooks","issue_events_url":"https://api.github.com/repos/zaki50/realm-java/issues/events{/number}","events_url":"https://api.github.com/repos/zaki50/realm-java/events","assignees_url":"https://api.github.com/repos/zaki50/realm-java/assignees{/user}","branches_url":"https://api.github.com/repos/zaki50/realm-java/branches{/branch}","tags_url":"https://api.github.com/repos/zaki50/realm-java/tags","blobs_url":"https://api.github.com/repos/zaki50/realm-java/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/zaki50/realm-java/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/zaki50/realm-java/git/refs{/sha}","trees_url":"https://api.github.com/repos/zaki50/realm-java/git/trees{/sha}","statuses_url":"https://api.github.com/repos/zaki50/realm-java/statuses/{sha}","languages_url":"https://api.github.com/repos/zaki50/realm-java/languages","stargazers_url":"https://api.github.com/repos/zaki50/realm-java/stargazers","contributors_url":"https://api.github.com/repos/zaki50/realm-java/contributors","subscribers_url":"https://api.github.com/repos/zaki50/realm-java/subscribers","subscription_url":"https://api.github.com/repos/zaki50/realm-java/subscription","commits_url":"https://api.github.com/repos/zaki50/realm-java/commits{/sha}","git_commits_url":"https://api.github.com/repos/zaki50/realm-java/git/commits{/sha}","comments_url":"https://api.github.com/repos/zaki50/realm-java/comments{/number}","issue_comment_url":"https://api.github.com/repos/zaki50/realm-java/issues/comments{/number}","contents_url":"https://api.github.com/repos/zaki50/realm-java/contents/{+path}","compare_url":"https://api.github.com/repos/zaki50/realm-java/compare/{base}...{head}","merges_url":"https://api.github.com/repos/zaki50/realm-java/merges","archive_url":"https://api.github.com/repos/zaki50/realm-java/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/zaki50/realm-java/downloads","issues_url":"https://api.github.com/repos/zaki50/realm-java/issues{/number}","pulls_url":"https://api.github.com/repos/zaki50/realm-java/pulls{/number}","milestones_url":"https://api.github.com/repos/zaki50/realm-java/milestones{/number}","notifications_url":"https://api.github.com/repos/zaki50/realm-java/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/zaki50/realm-java/labels{/name}","releases_url":"https://api.github.com/repos/zaki50/realm-java/releases{/id}","created_at":"2015-05-08T07:19:26Z","updated_at":"2015-05-08T07:19:27Z","pushed_at":"2015-09-22T04:38:10Z","git_url":"git://github.com/zaki50/realm-java.git","ssh_url":"git@github.com:zaki50/realm-java.git","clone_url":"https://github.com/zaki50/realm-java.git","svn_url":"https://github.com/zaki50/realm-java","homepage":"http://realm.io","size":38538,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"realm:master","ref":"master","sha":"6a648de48c7622f648785a2c0e90a3d38b7db076","user":{"login":"realm","id":7575099,"avatar_url":"https://avatars.githubusercontent.com/u/7575099?v=3","gravatar_id":"","url":"https://api.github.com/users/realm","html_url":"https://github.com/realm","followers_url":"https://api.github.com/users/realm/followers","following_url":"https://api.github.com/users/realm/following{/other_user}","gists_url":"https://api.github.com/users/realm/gists{/gist_id}","starred_url":"https://api.github.com/users/realm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/realm/subscriptions","organizations_url":"https://api.github.com/users/realm/orgs","repos_url":"https://api.github.com/users/realm/repos","events_url":"https://api.github.com/users/realm/events{/privacy}","received_events_url":"https://api.github.com/users/realm/received_events","type":"Organization","site_admin":false},"repo":{"id":4084908,"name":"realm-java","full_name":"realm/realm-java","owner":{"login":"realm","id":7575099,"avatar_url":"https://avatars.githubusercontent.com/u/7575099?v=3","gravatar_id":"","url":"https://api.github.com/users/realm","html_url":"https://github.com/realm","followers_url":"https://api.github.com/users/realm/followers","following_url":"https://api.github.com/users/realm/following{/other_user}","gists_url":"https://api.github.com/users/realm/gists{/gist_id}","starred_url":"https://api.github.com/users/realm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/realm/subscriptions","organizations_url":"https://api.github.com/users/realm/orgs","repos_url":"https://api.github.com/users/realm/repos","events_url":"https://api.github.com/users/realm/events{/privacy}","received_events_url":"https://api.github.com/users/realm/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/realm/realm-java","description":"Realm is a mobile database: a replacement for SQLite & ORMs","fork":false,"url":"https://api.github.com/repos/realm/realm-java","forks_url":"https://api.github.com/repos/realm/realm-java/forks","keys_url":"https://api.github.com/repos/realm/realm-java/keys{/key_id}","collaborators_url":"https://api.github.com/repos/realm/realm-java/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/realm/realm-java/teams","hooks_url":"https://api.github.com/repos/realm/realm-java/hooks","issue_events_url":"https://api.github.com/repos/realm/realm-java/issues/events{/number}","events_url":"https://api.github.com/repos/realm/realm-java/events","assignees_url":"https://api.github.com/repos/realm/realm-java/assignees{/user}","branches_url":"https://api.github.com/repos/realm/realm-java/branches{/branch}","tags_url":"https://api.github.com/repos/realm/realm-java/tags","blobs_url":"https://api.github.com/repos/realm/realm-java/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/realm/realm-java/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/realm/realm-java/git/refs{/sha}","trees_url":"https://api.github.com/repos/realm/realm-java/git/trees{/sha}","statuses_url":"https://api.github.com/repos/realm/realm-java/statuses/{sha}","languages_url":"https://api.github.com/repos/realm/realm-java/languages","stargazers_url":"https://api.github.com/repos/realm/realm-java/stargazers","contributors_url":"https://api.github.com/repos/realm/realm-java/contributors","subscribers_url":"https://api.github.com/repos/realm/realm-java/subscribers","subscription_url":"https://api.github.com/repos/realm/realm-java/subscription","commits_url":"https://api.github.com/repos/realm/realm-java/commits{/sha}","git_commits_url":"https://api.github.com/repos/realm/realm-java/git/commits{/sha}","comments_url":"https://api.github.com/repos/realm/realm-java/comments{/number}","issue_comment_url":"https://api.github.com/repos/realm/realm-java/issues/comments{/number}","contents_url":"https://api.github.com/repos/realm/realm-java/contents/{+path}","compare_url":"https://api.github.com/repos/realm/realm-java/compare/{base}...{head}","merges_url":"https://api.github.com/repos/realm/realm-java/merges","archive_url":"https://api.github.com/repos/realm/realm-java/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/realm/realm-java/downloads","issues_url":"https://api.github.com/repos/realm/realm-java/issues{/number}","pulls_url":"https://api.github.com/repos/realm/realm-java/pulls{/number}","milestones_url":"https://api.github.com/repos/realm/realm-java/milestones{/number}","notifications_url":"https://api.github.com/repos/realm/realm-java/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/realm/realm-java/labels{/name}","releases_url":"https://api.github.com/repos/realm/realm-java/releases{/id}","created_at":"2012-04-20T09:18:42Z","updated_at":"2015-09-21T22:44:58Z","pushed_at":"2015-09-22T06:28:17Z","git_url":"git://github.com/realm/realm-java.git","ssh_url":"git@github.com:realm/realm-java.git","clone_url":"https://github.com/realm/realm-java.git","svn_url":"https://github.com/realm/realm-java","homepage":"http://realm.io","size":57495,"stargazers_count":2503,"watchers_count":2503,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":252,"mirror_url":null,"open_issues_count":158,"forks":252,"open_issues":158,"watchers":2503,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/realm/realm-java/pulls/1488"},"html":{"href":"https://github.com/realm/realm-java/pull/1488"},"issue":{"href":"https://api.github.com/repos/realm/realm-java/issues/1488"},"comments":{"href":"https://api.github.com/repos/realm/realm-java/issues/1488/comments"},"review_comments":{"href":"https://api.github.com/repos/realm/realm-java/pulls/1488/comments"},"review_comment":{"href":"https://api.github.com/repos/realm/realm-java/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/realm/realm-java/pulls/1488/commits"},"statuses":{"href":"https://api.github.com/repos/realm/realm-java/statuses/654a202d6fbee55c12fd7256546c4d299b634be6"}}}}