java - vaadin & Spring 启动 : compiled widgetset is missed in jar package

标签 java spring maven spring-boot vaadin

我已经使用在 spring boot 上运行的 Vaadin 实现了一个 web 应用程序。 Maven 用于构建可执行的jar 包。这运行得很好。 但现在我已经添加了一个自定义小部件集......只是一个渲染器,能够在网格内使用字体很棒的标签按钮(https://vaadin.com/forum/#!/thread/9225584/10109123)。

在 Maven 构建过程中,我可以看到 widgetset 将被编译。我希望在 VAADIN/widgetsets/文件夹中编译 widgetset,但它在 jar 包中丢失。 如果我将 pom.xml 中的打包信息更改为“war”,widgetset 将被复制到包中。

有什么想法可以将已编译的小部件集复制到 jar 中吗??

这是我的 pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
  <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>de.myCompany.app</groupId>
  <artifactId>web-ui</artifactId>
  <version>1.1.0-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>Web-UI</name>
  <description>Web UI</description>

  <parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.2.1.RELEASE</version>
  </parent>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <aspectj.skip>false</aspectj.skip>
    <jgitflow.version>1.0-m5.1</jgitflow.version>

    <!-- dependencies version -->
    <vaadin.version>7.5.4</vaadin.version>
    <app.version>2.3.0-SNAPSHOT</app.version>
    <jason.version>1.4.0-SNAPSHOT</jason.version>

    <!-- application.properties -->
    <server.port>8085</server.port>
  </properties>

  <scm>
     <connection>scm:git:user3@service1.sb.intranet.de:WebUI.git</connection>
    <developerConnection>scm:git:user3@service1.sb.intranet.de:WebUI.git</developerConnection>
    <tag>HEAD</tag>
</scm>

<distributionManagement>
    <repository>
        <id>nexus</id>
        <name>Internal Releases</name>
        <url>https://nexus.sb.intranet.de/content/repositories/releases/</url>
    </repository>
    <snapshotRepository>
        <id>nexus</id>
        <name>Internal Snapshots</name>
        <url>https://nexus.sb.intranet.de/content/repositories/snapshots/</url>
    </snapshotRepository>
</distributionManagement>

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>com.vaadin</groupId>
            <artifactId>vaadin-bom</artifactId>
            <version>${vaadin.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

<build>
    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.3</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>

        <!-- Ensure the widgetset directory is cleaned properly -->
        <plugin>
            <artifactId>maven-clean-plugin</artifactId>
            <version>2.6.1</version>
            <configuration>
                <filesets>
                    <fileset>
                        <!-- Clean-up widgetset required for "inplace" compilation -->
                        <directory>${basedir}/src/main/webapp/VAADIN/widgetsets</directory>
                    </fileset>
                    <fileset>
                        <!-- Clean-up gwt cache -->
                        <directory>${basedir}/src/main/webapp/VAADIN/gwt-unitCache</directory>
                    </fileset>
                </filesets>
            </configuration>
        </plugin>           

        <plugin>
            <groupId>com.vaadin</groupId>
            <artifactId>vaadin-maven-plugin</artifactId>
            <version>${vaadin.version}</version>
            <configuration>
                <extraJvmArgs>-Xmx512M -Xss1024k</extraJvmArgs>
                <webappDirectory>${basedir}/src/main/webapp/VAADIN/widgetsets</webappDirectory>
                <hostedWebapp>${basedir}/src/main/webapp/VAADIN/widgetsets</hostedWebapp>
                <noServer>true</noServer>
                <persistentunitcachedir>${basedir}/target/tmp/gwt-unitCache</persistentunitcachedir>
                <compileReport>true</compileReport>
                <strict>true</strict>
                <runTarget>http://localhost:${server.port}/</runTarget>
            </configuration>
            <executions>
                <execution>
                    <configuration>
                        <!-- no specified modules; the plugin will find them automatically-->
                    </configuration>
                    <goals>
                        <!--goal>clean</goal>
                        <goal>resources</goal>
                        <goal>update-theme</goal>
                        <goal>update-widgetset</goal>
                        <goal>compile-theme</goal>
                        <goal>compile</goal-->
                        <goal>resources</goal>
                        <goal>update-widgetset</goal>
                        <goal>compile</goal>
                        <goal>resources</goal>
                    </goals>
                </execution>
            </executions>                
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
            <version>2.10.1</version>
            <configuration>
                <tags>
                    <tag>
                        <name>company</name>
                        <placement>a</placement>
                        <head>Company:</head>
                    </tag>
                    <tag>
                        <name>date</name>
                        <placement>a</placement>
                        <head>Creation:</head>
                    </tag>
                </tags>
                <additionalparam>-Xdoclint:none</additionalparam>
            </configuration>
        </plugin>

        <plugin>
            <groupId>external.atlassian.jgitflow</groupId>
            <artifactId>jgitflow-maven-plugin</artifactId>
            <version>${jgitflow.version}</version>
            <configuration>
                <allowSnapshots>true</allowSnapshots>
                <flowInitContext>
                    <masterBranchName>master</masterBranchName>
                    <developBranchName>develop</developBranchName>
                    <releaseBranchPrefix>release-</releaseBranchPrefix>
                    <hotfixBranchPrefix>hotfix-</hotfixBranchPrefix>
                    <versionTagPrefix>V</versionTagPrefix>
                </flowInitContext>
            </configuration>
        </plugin>

    </plugins> 

    <resources>
        <resource>
            <directory>src/main/webapp</directory>
            <filtering>true</filtering>
            <excludes>
                <exclude>**/*.scss</exclude>                    
            </excludes>
        </resource>
        <resource>
            <directory>src/main/resources</directory>
            <filtering>true</filtering>
        </resource>
        <resource>
            <directory>src/main/resources</directory>
            <includes>
                <include>platforms.json</include>
            </includes>
            <targetPath>${project.build.directory}/config</targetPath>
            <filtering>true</filtering>
        </resource>
    </resources>        
</build>

<dependencies>
    <dependency>
        <groupId>org.vaadin.spring</groupId>
        <artifactId>spring-boot-vaadin</artifactId>
        <version>0.0.3</version>
    </dependency>
    <dependency>
        <groupId>com.vaadin</groupId>
        <artifactId>vaadin-server</artifactId>
    </dependency>
    <dependency>
        <groupId>com.vaadin</groupId>
        <artifactId>vaadin-client-compiler</artifactId>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>com.vaadin</groupId>
        <artifactId>vaadin-client-compiled</artifactId>
    </dependency>
    <dependency>
        <groupId>com.vaadin</groupId>
        <artifactId>vaadin-client</artifactId>
        <scope>provided</scope>
    </dependency>     
    <dependency>
        <groupId>com.vaadin</groupId>
        <artifactId>vaadin-themes</artifactId>
    </dependency>
    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-lang3</artifactId>
        <version>3.4</version>
    </dependency>
    <dependency>
        <groupId>javax.validation</groupId>
        <artifactId>validation-api</artifactId>
        <version>1.1.0.Final</version>
    </dependency>
    <dependency>
        <groupId>com.google.code.gson</groupId>
        <artifactId>gson</artifactId>
        <version>2.2.4</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <version>${project.parent.version}</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>3.1.0</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>
    <dependency>
        <groupId>de.myCompany.app</groupId>
        <artifactId>generic-agent-control-common</artifactId>
        <version>${app.version}</version>
    </dependency>
    <dependency>
        <groupId>com.google.gwt</groupId>
        <artifactId>gwt-user</artifactId>
        <version>2.7.0</version>
    </dependency>
    <dependency>
        <groupId>de.myCompany.app</groupId>
        <artifactId>control-client</artifactId>
        <version>1.5.0-SNAPSHOT</version>
    </dependency>
    <dependency>
        <groupId>de.myCompany.app</groupId>
        <artifactId>control-json</artifactId>
        <version>${app.version}</version>
    </dependency>
</dependencies>

<profiles>
    <profile>
        <!--This profile setup logging level to dump only errors out. To
        contribute with this mechanism the placeholders "${logger.level}" and "${logger.app.level}"
        must be used inside the lockback.xml file or "application.properties" for level definitions
        instead of fix level definitions like "info", "debug",.. -->
        <id>quiet</id>
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>
        <properties>
            <logger.level>ERROR</logger.level>
            <logger.app.level>WARN</logger.app.level>
            <surefire.reportFormat>plain</surefire.reportFormat>
            <surefire.printSummary>true</surefire.printSummary>
            <surefire.useFile>true</surefire.useFile>
        </properties>
    </profile>
    <profile>
        <!-- This profile setup logging level to dump detailed informations.
        See profile "quietTest" above for more details -->
        <id>verbose</id>
        <properties>
            <logger.level>DEBUG</logger.level>
            <logger.app.level>TRACE</logger.app.level>
            <surefire.reportFormat>plain</surefire.reportFormat>
            <surefire.printSummary>true</surefire.printSummary>
            <surefire.useFile>false</surefire.useFile>
        </properties>
    </profile>
    <profile>
        <!--+ This profile setup logging level to dump detailed informations.
        See profile "quietTest" above for more details + -->
        <id>info</id>
        <activation>
            <property>
                <name>verboseTest</name>
            </property>
        </activation>
        <properties>
            <logger.level>WARN</logger.level>
            <logger.app.level>INFO</logger.app.level>
            <surefire.reportFormat>plain</surefire.reportFormat>
            <surefire.printSummary>true</surefire.printSummary>
            <surefire.useFile>false</surefire.useFile>
        </properties>
    </profile>
</profiles>

最佳答案

@morfic 感谢您的启发。 :-)

这是我的解决方案,效果很好! (也在带有 Vaadin 插件的 Netbeans IDE 中):

  1. 我将 vaadin maven 插件的执行阶段设置为“编译”
  2. 我添加了一个额外的 maven 资源插件,执行阶段为“process-classes”

这是我的pom:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>de.myCompany.app</groupId>
<artifactId>web-ui</artifactId>
<version>1.1.0-SNAPSHOT</version>
<packaging>jar</packaging>

<name>Web-UI</name>
<description>Web UI</description>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.2.1.RELEASE</version>
</parent>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <aspectj.skip>false</aspectj.skip>
    <jgitflow.version>1.0-m5.1</jgitflow.version>

    <!-- dependencies version -->
    <vaadin.version>7.5.4</vaadin.version>
    <app.version>2.3.0-SNAPSHOT</app.version>
    <jason.version>1.4.0-SNAPSHOT</jason.version>

    <!-- application.properties -->
    <server.port>8085</server.port>
</properties>

<scm>
    <connection>scm:git:user3@service1.sb.intranet.de:WebUI.git</connection>
    <developerConnection>scm:git:user3@service1.sb.intranet.de:WebUI.git</developerConnection>
    <tag>HEAD</tag>
</scm>

<distributionManagement>
    <repository>
        <id>nexus</id>
        <name>Internal Releases</name>
        <url>https://nexus.sb.intranet.de/content/repositories/releases/</url>
    </repository>
    <snapshotRepository>
        <id>nexus</id>
        <name>Internal Snapshots</name>
        <url>https://nexus.sb.intranet.de/content/repositories/snapshots/</url>
    </snapshotRepository>
</distributionManagement>

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>com.vaadin</groupId>
            <artifactId>vaadin-bom</artifactId>
            <version>${vaadin.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

<build>
    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.3</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>

        <!-- Ensure the widgetset directory is cleaned properly -->
        <plugin>
            <artifactId>maven-clean-plugin</artifactId>
            <version>2.6.1</version>
            <configuration>
                <filesets>
                    <fileset>
                        <!-- Clean-up widgetset required for "inplace" compilation -->
                        <directory>${basedir}/src/main/webapp/VAADIN/widgetsets</directory>
                    </fileset>
                    <fileset>
                        <!-- Clean-up gwt cache -->
                        <directory>${basedir}/src/main/webapp/VAADIN/gwt-unitCache</directory>
                    </fileset>
                </filesets>
            </configuration>
        </plugin>           

        <plugin>
            <groupId>com.vaadin</groupId>
            <artifactId>vaadin-maven-plugin</artifactId>
            <version>${vaadin.version}</version>
            <configuration>
                <extraJvmArgs>-Xmx512M -Xss1024k</extraJvmArgs>
                <webappDirectory>${basedir}/src/main/webapp/VAADIN/widgetsets</webappDirectory>
                <hostedWebapp>${basedir}/src/main/webapp/VAADIN/widgetsets</hostedWebapp>
                <noServer>true</noServer>
                <persistentunitcachedir>${basedir}/target/tmp/gwt-unitCache</persistentunitcachedir>
                <compileReport>true</compileReport>
                <strict>true</strict>
                <runTarget>http://localhost:${server.port}/</runTarget>
            </configuration>
            <executions>
                <execution>
                    <configuration>
                        <!-- no specified modules; the plugin will find them automatically-->
                    </configuration>
                    <phase>compile</phase>
                    <goals>
                        <goal>clean</goal>
                        <goal>resources</goal>
                        <goal>update-theme</goal>
                        <goal>update-widgetset</goal>
                        <goal>compile-theme</goal>
                        <goal>compile</goal>
                    </goals>
                </execution>
            </executions>                
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
            <version>2.10.1</version>
            <configuration>
                <tags>
                    <tag>
                        <name>company</name>
                        <placement>a</placement>
                        <head>Company:</head>
                    </tag>
                    <tag>
                        <name>date</name>
                        <placement>a</placement>
                        <head>Creation:</head>
                    </tag>
                </tags>
                <additionalparam>-Xdoclint:none</additionalparam>
            </configuration>
        </plugin>

        <plugin>
            <artifactId>maven-resources-plugin</artifactId>
            <version>2.7</version>
            <executions>
                <execution>
                    <id>copy-resources</id>
                    <phase>process-classes</phase>
                    <goals>                            
                        <goal>copy-resources</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>${basedir}/target/classes</outputDirectory>
                        <resources>          
                            <resource>
                                <directory>src/main/webapp</directory>
                                <excludes>
                                    <exclude>**/*.scss</exclude>                    
                                </excludes>
                            </resource>
                        </resources>              
                    </configuration>            
                </execution>
            </executions>
        </plugin>

        <plugin>
            <groupId>external.atlassian.jgitflow</groupId>
            <artifactId>jgitflow-maven-plugin</artifactId>
            <version>${jgitflow.version}</version>
            <configuration>
                <allowSnapshots>true</allowSnapshots>
                <flowInitContext>
                    <masterBranchName>master</masterBranchName>
                    <developBranchName>develop</developBranchName>
                    <releaseBranchPrefix>release-</releaseBranchPrefix>
                    <hotfixBranchPrefix>hotfix-</hotfixBranchPrefix>
                    <versionTagPrefix>V</versionTagPrefix>
                </flowInitContext>
            </configuration>
        </plugin>

    </plugins> 

    <resources>      
        <resource>
            <directory>src/main/resources</directory>
            <filtering>true</filtering>
        </resource>
        <resource>
            <directory>src/main/resources</directory>
            <includes>
                <include>platforms.json</include>
            </includes>
            <targetPath>${project.build.directory}/config</targetPath>
            <filtering>true</filtering>
        </resource>
    </resources>        
</build>

<dependencies>
    <dependency>
        <groupId>org.vaadin.spring</groupId>
        <artifactId>spring-boot-vaadin</artifactId>
        <version>0.0.3</version>
    </dependency>
    <dependency>
        <groupId>com.vaadin</groupId>
        <artifactId>vaadin-server</artifactId>
    </dependency>
    <dependency>
        <groupId>com.vaadin</groupId>
        <artifactId>vaadin-client-compiler</artifactId>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>com.vaadin</groupId>
        <artifactId>vaadin-client-compiled</artifactId>
    </dependency>
    <dependency>
        <groupId>com.vaadin</groupId>
        <artifactId>vaadin-client</artifactId>
        <scope>provided</scope>
    </dependency>     
    <dependency>
        <groupId>com.vaadin</groupId>
        <artifactId>vaadin-themes</artifactId>
    </dependency>
    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-lang3</artifactId>
        <version>3.4</version>
    </dependency>
    <dependency>
        <groupId>javax.validation</groupId>
        <artifactId>validation-api</artifactId>
        <version>1.1.0.Final</version>
    </dependency>
    <dependency>
        <groupId>com.google.code.gson</groupId>
        <artifactId>gson</artifactId>
        <version>2.2.4</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <version>${project.parent.version}</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>3.1.0</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>
    <dependency>
        <groupId>de.myCompany.app</groupId>
        <artifactId>control-common</artifactId>
        <version>${app.version}</version>
    </dependency>
    <dependency>
        <groupId>com.google.gwt</groupId>
        <artifactId>gwt-user</artifactId>
        <version>2.7.0</version>
    </dependency>
    <dependency>
        <groupId>de.myCompany.app</groupId>
        <artifactId>control-client</artifactId>
        <version>1.5.0-SNAPSHOT</version>
    </dependency>
    <dependency>
        <groupId>de.myCompany.app</groupId>
        <artifactId>generic-agent-control-json</artifactId>
        <version>${app.version}</version>
    </dependency>
</dependencies>

<profiles>
    <profile>
        <!--This profile setup logging level to dump only errors out. To
        contribute with this mechanism the placeholders "${logger.level}" and "${logger.app.level}"
        must be used inside the lockback.xml file or "application.properties" for level definitions
        instead of fix level definitions like "info", "debug",.. -->
        <id>quiet</id>
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>
        <properties>
            <logger.level>ERROR</logger.level>
            <logger.app.level>WARN</logger.app.level>
            <surefire.reportFormat>plain</surefire.reportFormat>
            <surefire.printSummary>true</surefire.printSummary>
            <surefire.useFile>true</surefire.useFile>
        </properties>
    </profile>
    <profile>
        <!-- This profile setup logging level to dump detailed informations.
        See profile "quietTest" above for more details -->
        <id>verbose</id>
        <properties>
            <logger.level>DEBUG</logger.level>
            <logger.app.level>TRACE</logger.app.level>
            <surefire.reportFormat>plain</surefire.reportFormat>
            <surefire.printSummary>true</surefire.printSummary>
            <surefire.useFile>false</surefire.useFile>
        </properties>
    </profile>
    <profile>
        <!--+ This profile setup logging level to dump detailed informations.
        See profile "quietTest" above for more details + -->
        <id>info</id>
        <activation>
            <property>
                <name>verboseTest</name>
            </property>
        </activation>
        <properties>
            <logger.level>WARN</logger.level>
            <logger.app.level>INFO</logger.app.level>
            <surefire.reportFormat>plain</surefire.reportFormat>
            <surefire.printSummary>true</surefire.printSummary>
            <surefire.useFile>false</surefire.useFile>
        </properties>
    </profile>
</profiles>

关于java - vaadin & Spring 启动 : compiled widgetset is missed in jar package,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32326361/

相关文章:

maven - JFrog Artifactory : Difference between item, 神器,构建和入口?

java - 访问 Spring Session 范围的代理 Bean

spring - 关于spring Rowmapper、mapRow

Java将负/正字符串数字转换为负/正 double

java - JADE - 代理托管 Web 服务 (wsdl)

spring - Spring MVC 和 Spring Boot 的区别

java - 如何使用 Maven 创建具有依赖项的不可执行 JAR?

java - 从头开始构建Eclipse IDE-如何通过JDT选择CDT?

c# - 如何确定 Windows Java 安装位置

java - 基于 Solr 规则的提升