Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make vaadinPrepareFrontend and vaadinBuildFrontend activate automatically #48

Closed
mvysny opened this issue Feb 26, 2020 · 0 comments · Fixed by #49
Closed

Make vaadinPrepareFrontend and vaadinBuildFrontend activate automatically #48

mvysny opened this issue Feb 26, 2020 · 0 comments · Fixed by #49
Assignees
Milestone

Comments

@mvysny
Copy link
Member

mvysny commented Feb 26, 2020

Currently the production mode auto-activates when you call Gradle with task vaadinBuildFrontend. That's because Gradle doesn't use profiles the way Maven does. However, this approach is pretty fragile:

  1. There is a bug: the production mode doesn't auto-activate if you just call ./gradlew and you have defaultTasks("clean", "vaadinBuildFrontend", "build") in your build.gradle file.
  2. The production mode doesn't auto-activate if you have build.dependsOn("vaadinBuildFrontend") in your build.gradle file.
  3. You can enforce the production mode by using vaadin { productionMode = true } in your build.gradle file, but it's not a solid approach to control this by editing build.gradle - you don't want your CI to edit your build.gradle

We should either fix this behavior for the productionMode to auto-activate properly whenever vaadinBuildFrontend task is to be executed, or we should make the productionMode setting respond to e.g. ./gradlew blah blah -Dvaadin.productionMode=true.

I wonder if there is any merit in having a WAR file with development mode. The disadvantage is apparent: customers would drop a WAR file into production, and the WAR file will start downloading and populating node_modules. But on the development machine one can wish to e.g. deploy a WAR file into local Tomcat for development purposes, which is also a valid approach. And vice versa - some people who do not want to touch JavaScript at all, will be pretty fine developing having the productionMode turned on.

Sounds to me that the best strategy is to let the developer flip the productionMode switch (either by system property, or permanently in build.gradle), and the build should accommodate accordingly (e.g. auto-call vaadinBuildFrontend but only when the productionMode is true; and auto-call vaadinPrepareFrontend always when the plugin is applied).

This would however auto-create frontend/ folders for every java-based subproject. We should document cleanly how to use the plugin in multi-project builds:

plugins {
  id 'java'
  id "com.vaadin" version "0.5.1" apply false
}

project("lib") {
  apply plugin: 'java'
}
project("web") {
  apply plugin: 'war'
  apply plugin: "com.vaadin"
}
@mvysny mvysny self-assigned this Feb 26, 2020
mvysny added a commit that referenced this issue Feb 26, 2020
@caalador caalador added this to the 0.6.0 milestone Feb 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants