robert-w-gries / javar

Java compiler written in Java
0 stars 0 forks source link

Improve build system #1

Open robert-w-gries opened 6 years ago

robert-w-gries commented 6 years ago

Edit: After discussion, we've removed the Makefile and are changing to gradle for our build system.

Tasks:


Original Post:

Makefile needs to be updated to reflect the new code organization structure

jchitel commented 6 years ago

RE: our offline conversation

Right now I see several problems with our current build process:

  1. The directories containing .java files are statically defined in the Makefile. We ran into problems with this immediately when we changed the directory organization. This can be fixed by replacing the javac build logic with a simple javac call targeted at the Main.java file, or the whole src/ directory (I'm not sure which is the correct way to do it in Java). That means replacing lines 20-66 of the Makefile with ~3 lines that call javac. This would mean losing the incremental building aspect of Make (there may be a way to keep this but dynamically resolve the source files), but the project is small enough that it doesn't really matter right now.
  2. Make is complicated. Even if someone takes the time to learn how it works, it is unintuitive and requires unnecessary boilerplate. I find that the best build tools are those that are designed specifically for the chosen stack, because they have a built-in understanding of the language, how dependencies are resolved, the required inputs and outputs, etc. This is why I suggested maven and gradle.
  3. We don't currently have JavaCC in the project. It was available as a global binary on the systems lab computers. If we want to be able to build the .jj files we have, we need to install JavaCC somehow, whether that's downloading the executable and including it in the project, or installing it through some dependency management system (another point in favor of maven and gradle).
  4. Right now, we need to build the parser, and then build the full application, because the source files are dependent on the JavaCC output. This would be fairly easy to add to the Makefile or to some other build system.

Based on point 3 alone, we need a build system that comes with dependency management, which Make does not have. I'm going to recommend that we use Gradle, because it has everything we need, it is made for Java projects, and it was created based on the shortcomings of Make, Ant, and Maven. It also has a super clean and easy to read syntax. And it's supported by Travis.

robert-w-gries commented 6 years ago

Consider me convinced 😃

I still think Make is a valid tool for build automation, but it just doesn't make sense for a large Java project. Gradle seems like a solid alternative, since I vaguely remember disliking Maven three years ago haha.

JavaCC through Gradle seems like it would work. It's an easy manual instal. So if JavaCC gradle plugin doesn't work, we can just list it as a dependency on our Readme and provide a link to download it.

Regarding point 4, we are tracking the generated parser files so there's no requirement to build the parser. It'd be nice to automatically re-generate the parser files when we change the .jj files through the plugin.

jchitel commented 6 years ago

I would say:

  1. Try with the JavaCC plugin per your link.
  2. Install JavaCC through a normal dependency and add a build step to call it manually, still using Gradle.
  3. Readme link.

If 1 doesn't work, I'd really try to get 2 working, with 3 as an absolute last resort. Automation is awesome, so if we can get that working, that would be ideal. I don't like having to manually install dependencies.