{"action":"closed","issue":{"url":"https://api.github.com/repos/revelc/formatter-maven-plugin/issues/29","labels_url":"https://api.github.com/repos/revelc/formatter-maven-plugin/issues/29/labels{/name}","comments_url":"https://api.github.com/repos/revelc/formatter-maven-plugin/issues/29/comments","events_url":"https://api.github.com/repos/revelc/formatter-maven-plugin/issues/29/events","html_url":"https://github.com/revelc/formatter-maven-plugin/issues/29","id":61369477,"number":29,"title":"Support filtering out non-writable source files for Perforce compatibility.","user":{"login":"GoogleCodeExporter","id":9614759,"avatar_url":"https://avatars.githubusercontent.com/u/9614759?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleCodeExporter","html_url":"https://github.com/GoogleCodeExporter","followers_url":"https://api.github.com/users/GoogleCodeExporter/followers","following_url":"https://api.github.com/users/GoogleCodeExporter/following{/other_user}","gists_url":"https://api.github.com/users/GoogleCodeExporter/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleCodeExporter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleCodeExporter/subscriptions","organizations_url":"https://api.github.com/users/GoogleCodeExporter/orgs","repos_url":"https://api.github.com/users/GoogleCodeExporter/repos","events_url":"https://api.github.com/users/GoogleCodeExporter/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleCodeExporter/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/revelc/formatter-maven-plugin/labels/auto-migrated","name":"auto-migrated","color":"ededed"},{"url":"https://api.github.com/repos/revelc/formatter-maven-plugin/labels/Priority-Medium","name":"Priority-Medium","color":"ededed"},{"url":"https://api.github.com/repos/revelc/formatter-maven-plugin/labels/Type-Defect","name":"Type-Defect","color":"ededed"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-03-14T02:49:41Z","updated_at":"2015-05-13T18:20:41Z","closed_at":"2015-05-13T18:20:41Z","body":"```\nThe plugin is awesome - just what I needed - except for the fact that it \nexpects all the .java source files to be writable.  Unfortunately, perforce \n(scm) manages file permissions (read-only vs read-write) based on state \n(checked-out, etc).  So for a normal use case only the files you've modified \nand are submitting will be writable.  \n\nYou can see where this is going… The formatter plugin expects all the files \nin the PlexusIoFileResourceCollection to be writable.  This results in an \nexception being logged for every non-writable file.\n\nSooo…. It would be awesome to have a way to skip non-writable files in a \nfairly silent manner.  I've downloaded the source code and made a couple of \nvery minor edits (see below) to expose a new <configuration> flag called \n<writePermissionCheck> to indicate whether to skip non-writable files.  This is \njust meant as an aid in describing the idea of what I'm looking for - feel free \nto modify : )\n\nI can build/run my local copy, but it would be great if such an enhancement \ncould be rolled into an official version so that other perforce users could \ntake advantage of the plugin.   Thanks again for creating this useful utility!\n\nExpected output:\n - Non writable source files are \"silently\" skipped.\n\nActual output:\n - Non writable source files cause an exception in the build.\n\nSteps to reproduce:\n1.  Change a source .java file permissions to read-only and run the formatter.\n2.  Notice that an exception is written to the console because the file could \nnot be modified.\n\n\nPlugin version: 0.5-SNAPSHOT (trunk 127)\nMaven version: 2.2.1\nJava version: 1.7.0_10\nEclipse version: 4.2 (Juno) & 4.3 (Kepler)\nOS:  OSX & Windows7\n\nAdditional details:\n\nChange the FormatterMojo class as follows…\n\n  1.  Added a new permission check flag, defaults to false for backwards compatibility…\n\n\t/**\n\t * Perform a permissions check on all candidate files,\n\t * excluding files that are not writable.\n\t * \n\t * @parameter default-value=\"false\"\n\t * @since 0.5\n\t */\n\tprivate Boolean writePermissionCheck;\n\n\n  2. Implement the new check if specified…\n\n\t/**\n\t * Format individual file.\n\t * \n\t * @param file\n\t * @param rc\n\t * @param hashCache\n\t * @param basedirPath\n\t * @throws IOException\n\t * @throws BadLocationException\n\t */\n\tprivate void doFormatFile(File file, ResultCollector rc,\n\t\t\tProperties hashCache, String basedirPath) throws IOException,\n\t\t\tBadLocationException {\n\t\tLog log = getLog();\n\t\tlog.debug(\"Processing file: \" + file);\n\t\t\n\t\t// If Requested Perform Writable Check & Skip If Not Writable\n\t\tif(writePermissionCheck && !Files.isWritable(file.toPath()))\n\t\t{\t\n\t\t\trc.skippedCount++;\n\t\t\tlog.debug(\"File is not writable.\");\n\t\t\treturn;\n\t\t}\n\t\t…\n\n```\n\nOriginal issue reported on code.google.com by `minke.tr...@gmail.com` on 12 Sep 2013 at 5:04"}}