{"action":"created","issue":{"url":"https://api.github.com/repos/processing/processing/issues/5468","repository_url":"https://api.github.com/repos/processing/processing","labels_url":"https://api.github.com/repos/processing/processing/issues/5468/labels{/name}","comments_url":"https://api.github.com/repos/processing/processing/issues/5468/comments","events_url":"https://api.github.com/repos/processing/processing/issues/5468/events","html_url":"https://github.com/processing/processing/issues/5468","id":313084127,"number":5468,"title":"Export via processing-java is broken and has inconsistent design","user":{"login":"JoakimSoderberg","id":1446626,"avatar_url":"https://avatars3.githubusercontent.com/u/1446626?v=4","gravatar_id":"","url":"https://api.github.com/users/JoakimSoderberg","html_url":"https://github.com/JoakimSoderberg","followers_url":"https://api.github.com/users/JoakimSoderberg/followers","following_url":"https://api.github.com/users/JoakimSoderberg/following{/other_user}","gists_url":"https://api.github.com/users/JoakimSoderberg/gists{/gist_id}","starred_url":"https://api.github.com/users/JoakimSoderberg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JoakimSoderberg/subscriptions","organizations_url":"https://api.github.com/users/JoakimSoderberg/orgs","repos_url":"https://api.github.com/users/JoakimSoderberg/repos","events_url":"https://api.github.com/users/JoakimSoderberg/events{/privacy}","received_events_url":"https://api.github.com/users/JoakimSoderberg/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-04-10T20:50:12Z","updated_at":"2018-05-04T08:53:41Z","closed_at":null,"author_association":"NONE","body":"<!--- ** For coding questions, please use https://forum.processing.org ** -->\r\n<!--- ** This form is only for bugs in the software & feature requests ** -->\r\n\r\n<!--- ** Also be sure to read the troubleshooting page first: ** -->\r\n<!--- ** https://github.com/processing/processing/wiki/Troubleshooting ** -->\r\n\r\n<!--- ** Before posting, please search Issues for duplicates  ** --> \r\n\r\n## Description\r\n<!--- Use a title that describes what is happening. -->\r\n<!--- Give a description of the proposed change. -->\r\n\r\nHello and thank you for a nice application.\r\n\r\nI'm creating a project where I want to be able to export Processing sketch using a build scripts in a consistent way (not via the GUI).\r\n\r\nHowevre using the `processing-java` cli is very inconsistent and randomly fails silently. The code could need a good cleanup.\r\n\r\n## Expected Behavior\r\n<!--- Bug? Tell us what you were expecting. -->\r\n<!--- Improvement? Tell us how you’d like it to work. -->\r\n\r\n## Current Behavior\r\n<!--- Explain the difference from current behavior. -->\r\n\r\n### GUI (works fine)\r\n\r\nOpening a sketch inside of the GUI, and then doing **File -> Export Application** works fine:\r\n\r\n<img width=\"513\" alt=\"2018-04-10 22_06_08-flames _ processing 3 3 7\" src=\"https://user-images.githubusercontent.com/1446626/38580934-92c24506-3d0b-11e8-9673-d4a962e8a596.png\">\r\n\r\nThe export is placed in sub-directories in the sketch directory:\r\n\r\n<img width=\"183\" alt=\"2018-04-10 22_06_22-c__users_joaki_dev_siknas-skylt_examples_flames\" src=\"https://user-images.githubusercontent.com/1446626/38580974-b1c933e2-3d0b-11e8-9474-578a3c24996b.png\">\r\n\r\n### CLI\r\n\r\n#### Absolute paths required\r\n\r\nNow trying the same thing in the CLI is far from straightforward. First of all, when running `processing-java` the `cwd` seems to be the same directory as the executable, not the directory I am standing in (which is normal behavior for any other command).\r\n\r\nThis mean referencing relative directories will not work (The directory exists).\r\n\r\nExamples are using **git bash on Windows**. (Note `cmd.exe` has been tested, that is not the issue with these bugs).\r\n\r\n```bash\r\n$ processing-java --sketch=examples/flames --export  # It does exist\r\nexamples\\flames does not exist.\r\n```\r\n\r\nInstead I must use the **absolute path** for the command to find the sketch dir.\r\n\r\n#### Export fails silently\r\n\r\n```bash\r\n$ processing-java --sketch=$(pwd)/examples/flames/ --export\r\n```\r\n\r\nExcept when doing this, **there is no output** at all. Nothing gets created, and there are no errors.\r\n\r\n(I managed to get the above command working fine with the exact same command previously, but now I cannot reproduce this).\r\n\r\n### Help text\r\n\r\n```bash\r\n$ processing-java --help\r\n\r\nCommand line edition for Processing 0264 (Java Mode)\r\n\r\n--help               Show this help text. Congratulations.\r\n\r\n--sketch=<name>      Specify the sketch folder (required)\r\n--output=<name>      Specify the output folder (optional and\r\n                     cannot be the same as the sketch folder.)\r\n\r\n--force              The sketch will not build if the output\r\n                     folder already exists, because the contents\r\n                     will be replaced. This option erases the\r\n                     folder first. Use with extreme caution!\r\n\r\n--build              Preprocess and compile a sketch into .class files.\r\n--run                Preprocess, compile, and run a sketch.\r\n--present            Preprocess, compile, and run a sketch in presentation mode.\r\n\r\n--export             Export an application.\r\n--no-java            Do not embed Java. Use at your own risk!\r\n--platform           Specify the platform (export to application only).\r\n                     Should be one of 'windows', 'macosx', or 'linux'.\r\n\r\nThe --build, --run, --present, or --export must be the final parameter\r\npassed to Processing. Arguments passed following one of those four will\r\nbe passed through to the sketch itself, and therefore available to the\r\nsketch via the 'args' field. To pass options understood by PApplet.main(),\r\nwrite a custom main() method so that the preprocessor does not add one.\r\nhttps://github.com/processing/processing/wiki/Command-Line\r\n```\r\n\r\n### Iconsistency using `--export`, `--platform` and `--output`\r\n\r\nThe help text above might look helpful at a glance.\r\n\r\nHowever what it does not say is that if you specify an **output directory** using `--output=<path>`, it will export only for a single platform as specified using `--platform`.\r\n\r\nWhen only specifying `--export`, it will **export all platforms** in separate directories.\r\n\r\nI did not find this out until I looked at the code:\r\n\r\nhttps://github.com/processing/processing/blob/0abee5af6ad3b11cf2b73bb794b8a97c157c4762/java/src/processing/mode/java/Commander.java#L291-L301\r\n\r\n`--export` is doing something similar to what is done when exporting via the GUI menu:\r\n\r\nhttps://github.com/processing/processing/blob/f65616ae74b97ffc1762380141b7dbfe9cca4693/java/src/processing/mode/java/JavaEditor.java#L943-L948\r\n\r\n#### Error that is incorrect\r\n\r\nWhen running `--export` (and it happens to work sometimes?), or using the gui to export. Versions for both **Windows** and **Linux** are created fine.\r\n\r\nHowever when attempting to output the linux version it fails with an exception, which is not very helpful. The reason is that `--no-java` needs to be specified for that platform, which `JavaMode.handleExportApplication` seems to handle internally.\r\n\r\n```bash\r\n$ processing-java --sketch=$(pwd)/examples/flames/ --platform=linux --output=$(pwd)/bla --export\r\nException in thread \"main\" java.lang.RuntimeException: Not yet implemented on Windows\r\n        at processing.app.Util.copyDirNative(Util.java:270)\r\n        at processing.mode.java.JavaBuild.exportApplication(JavaBuild.java:848)\r\n        at processing.mode.java.Commander.<init>(Commander.java:299)\r\n        at processing.mode.java.Commander.main(Commander.java:86)\r\n\r\n$ processing-java --sketch=$(pwd)/examples/flames/ --platform=linux --output=$(pwd)/bla --no-java --export\r\nThe output folder already exists. Use --force to remove it.\r\n\r\n$ processing-java --sketch=$(pwd)/examples/flames/ --platform=linux --output=$(pwd)/bla --no-java --force --export\r\nFinished.\r\n\r\n$ ls bla/\r\ndata/  flames*  lib/  source/\r\n```\r\n\r\n#### Only a subset of the platforms are a choice\r\n\r\nAs seen in the help above only `windows`, `linux` and `macosx` are valid choices. However when exporting via the GUI, versions for multiple versions including 32/64 bit and ARM versions:\r\n\r\n```bash\r\n$ ls  -1 examples/flames/\r\napplication.linux32/\r\napplication.linux64/\r\napplication.linux-arm64/\r\napplication.linux-armv6hf/\r\napplication.windows32/\r\napplication.windows64/\r\n```\r\n\r\nThese are note possible to choose.\r\n\r\n## Steps to Reproduce\r\n<!--- Provide an unambiguous set of steps to reproduce. -->\r\n<!--- Including code will make it more likely to be fixed. -->\r\nSee above\r\n\r\n## Your Environment\r\n<!--- Include details about your environment. -->\r\n<!--- Thousands of people use Processing every day and may not have --> \r\n<!--- this issue, this might give us clues about why you’re seeing it. -->\r\n* Processing version: 3.3.7\r\n* Operating System and OS version: Windows 10\r\n* Other information: Tested on 2 PC:s\r\n\r\n## Possible Causes / Solutions\r\n<!--- Optionally, ideas on how to implement the change. -->\r\nThe solution is most likely to clean up and rewrite the command line parsing code to be more robust. And make the choices more consistent to match with what the GUI is able to export.\r\n\r\nBoth the GUI and the cli using `--export` (without `--output`) uses this function. But something is slightly different, so only the GUI works:\r\nhttps://github.com/processing/processing/blob/90522aa75fc85c4fcec84165c689d279167fa7ce/java/src/processing/mode/java/JavaMode.java#L237-L240\r\n\r\n* Make the help be much clearer\r\n* Rewrite the entire command line parser (Maybe use a lib? I'm no Java developer, but a quick google for a lib https://commons.apache.org/proper/commons-cli/)\r\n* Make the cli do the exact same thing that makes things work via the GUI.\r\n* Allow relative paths when running the cli.\r\n* Give full control to export/build all the types of targets, and control all the involved parameters\r\n* Give friendly error messages if the build fails\r\n* Do not exit the program silently without exporting anything, give an error if something is wrong\r\n\r\nIf I had more time I would probably fix this myself. But I'm not a Java programmer or am familiar with this code base. So for now I will find a quickfix for my issue. I just thought it would be good to open an issue on my thoughts."},"comment":{"url":"https://api.github.com/repos/processing/processing/issues/comments/386541634","html_url":"https://github.com/processing/processing/issues/5468#issuecomment-386541634","issue_url":"https://api.github.com/repos/processing/processing/issues/5468","id":386541634,"user":{"login":"liquid600pgm","id":16415678,"avatar_url":"https://avatars2.githubusercontent.com/u/16415678?v=4","gravatar_id":"","url":"https://api.github.com/users/liquid600pgm","html_url":"https://github.com/liquid600pgm","followers_url":"https://api.github.com/users/liquid600pgm/followers","following_url":"https://api.github.com/users/liquid600pgm/following{/other_user}","gists_url":"https://api.github.com/users/liquid600pgm/gists{/gist_id}","starred_url":"https://api.github.com/users/liquid600pgm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/liquid600pgm/subscriptions","organizations_url":"https://api.github.com/users/liquid600pgm/orgs","repos_url":"https://api.github.com/users/liquid600pgm/repos","events_url":"https://api.github.com/users/liquid600pgm/events{/privacy}","received_events_url":"https://api.github.com/users/liquid600pgm/received_events","type":"User","site_admin":false},"created_at":"2018-05-04T08:53:41Z","updated_at":"2018-05-04T08:53:41Z","author_association":"CONTRIBUTOR","body":"Can confirm all the issues. The inconsistencies with the CLI's `--export` argument made me switch to a proper IDE with a custom Ant script that is supposed to handle everything for me."}}
{"actor":{"display_login":"liquid600pgm"}}