Skip to content

Automatically exclude vaadin-dev-server from the production build #15749

Closed

Description

@Artur-

Describe your motivation

vaadin-dev-server contains development time dependencies that are never needed in production. Some of them are quite large.

Describe the solution you'd like

When building for production, mvn clean install -Pproduction the resulting jar (Spring boot) or war (others) should not contain vaadin-dev-server or its dependencies

Additional context

Related to #13922

Activity

  1. Artur- commented on Jan 27, 2023

    @Artur-
    MemberAuthor

    One way we could do this is to add a vaadin-dev platform level dependency and move vaadin-dev-server + vaadin-dev-bundle and potentially others there from vaadin-core. Then we need to change add the vaadin-dev dependency to each project like

            <profile>
                <id>development</id>
                <activation>
                    <activeByDefault>true</activeByDefault>
                </activation>
                <dependencies>
                    <dependency>
                        <groupId>com.vaadin</groupId>
                        <artifactId>vaadin-dev</artifactId>
                    </dependency>
                </dependencies>
            </profile>
    
  2. Artur- commented on Jan 27, 2023

    @Artur-
    MemberAuthor

    Not sure how easy this is to apply on Gradle projects

  3. ZheSun88 commented on Jan 27, 2023

    @ZheSun88
    Member

    one concern about the activeByDefault, as i read this from maven doc

    All profiles that are active by default are automatically deactivated when a profile in the POM is activated on the command line or through its activation config.
    

    so keep this as the only profile in the pom will work??

  4. Artur- commented on Jan 27, 2023

    @Artur-
    MemberAuthor

    The other option I can come up with is that vaadin includes vaadin-dev and we change the production profile to include

            <profile>
                <!-- Production mode is activated using -Pproduction -->
                <id>production</id>
                <dependencies>
                    <dependency>
                        <groupId>com.vaadin</groupId>
                        <artifactId>vaadin-core</artifactId>
                        <exclusions>
                            <exclusion>
                                <groupId>com.vaadin</groupId>
                                <artifactId>vaadin-dev</artifactId>
                            </exclusion>
                        </exclusions>
                    </dependency>
                </dependencies>
    
  5. bwolff commented on Jan 27, 2023

    @bwolff

    @Artur- Imho the solution to exclude the dependency in the production profile is the more better solution, also due to the issue raised by @ZheSun88.

    As for Gradle, I don't have a solution at hand, but I'm fairly certain that it will be quite easy to achieve the same exclude behavior when the production profile is active. Probably worth reaching out to the maintainers of the Vaadin Gradle plugin.

  6. Artur- commented on Jan 27, 2023

    @Artur-
    MemberAuthor

    I agree. Excluding it is kind of backwards compared to including only when needed, but it is still a better solution

  7. self-assigned this
    on Jan 27, 2023
  8. bwolff commented on Jan 27, 2023

    @bwolff

    You are right, it would be better to have an explicit include of the dev deps than an exclude. One option could be to use a profile that is only active when production is not active instead of using activeByDefault, like !production. But this might cause issues with other profiles like test...

    In any case, the exclude is already better than the current situation ;)

  9. mvysny commented on Jan 27, 2023

    @mvysny
    Member

    In Gradle, I can conditionally exclude an artifact in my project's build.gradle:

        implementation("com.vaadin:vaadin-core:23.3.5") {
            afterEvaluate {
                if (vaadin.productionMode) {
                    exclude(module: "vaadin-dev-server")
                }
            }
        }
    

    This seems to be working well: neither vaadin-dev-server nor its transitive dependencies are present in the zip, reducing the zip file size by ~8MB.

    Perhaps the same piece of code could be executed by the Gradle plugin automatically.

    Attaching the dependency tree of vaadin-dev-server for reference:

    |    +--- com.vaadin:vaadin-dev-server:23.3.3
    |    |    +--- com.vaadin:flow-server:23.3.3 (*)
    |    |    +--- com.vaadin:license-checker:1.11.2
    |    |    |    +--- com.vaadin.external.gwt:gwt-elemental:2.8.2.vaadin2
    |    |    |    +--- com.github.oshi:oshi-core:6.1.6
    |    |    |    |    +--- net.java.dev.jna:jna:5.11.0
    |    |    |    |    +--- net.java.dev.jna:jna-platform:5.11.0
    |    |    |    |    |    \--- net.java.dev.jna:jna:5.11.0
    |    |    |    |    \--- org.slf4j:slf4j-api:1.7.36 -> 2.0.5
    |    |    |    +--- org.slf4j:slf4j-api:1.7.36 -> 2.0.5
    |    |    |    +--- com.nimbusds:nimbus-jose-jwt:9.23
    |    |    |    +--- org.lucee:jcip-annotations:1.0.0
    |    |    |    \--- com.vaadin:open:8.4.0.3 -> 8.5.0
    |    |    |         \--- commons-io:commons-io:2.11.0
    |    |    \--- com.vaadin:open:8.5.0 (*)
    
  10. knoobie commented on Jan 27, 2023

    @knoobie
    Contributor

    I'm also +1 for the exclusion in the production profile. This could also be added to the projects created with start.vaadin.com and mentioned as recommendation in the 24.0 platform release.

  11. Artur- commented on Mar 10, 2023

    @Artur-
    MemberAuthor

    The platform artifacts have been fixed for 24.0.0 and the exclusion added to starters

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions