2015-09-01 70 views
1

我已經實現了一個帶有spring引導的Vaadin的web應用程序。 Maven被用來構建可執行的jar包。這運行得非常好。 但現在我已經添加了一個自定義的widgetset ...只是一個渲染器,可以使用網格內的字體真棒標籤按鈕(https://vaadin.com/forum/#!/thread/9225584/10109123)。vaadin&spring boot:編譯的widgetset錯過了jar包

在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:[email protected]:WebUI.git</connection> 
    <developerConnection>scm:git:[email protected]: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> 

+0

我一直一直出貨我的應用程序作爲戰爭所以我不能說你需要在戰爭中複製文件的位置,但一種做法是使用[maven資源插件](https://maven.apache.org/plugins/maven- resources-plugin /),請參閱你的''部分。如果這不夠靈活,那麼我會建議[maven assembly plugin](http://maven.apache.org/plugins/maven-assembly-plugin/) – Morfic

回答

2

@morfic謝謝你的靈感。 :-)

這是我的解決方案,它工作得很好! (也在Netbeans的IDE與Vaadin插件):

  1. 我的vaadin maven插件的執行階段設置爲「編譯」
  2. 我加入執行階段「的過程的類」
  3. 額外行家資源的插件

這是我的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:[email protected]:WebUI.git</connection> 
    <developerConnection>scm:git:[email protected]: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>