Solution basée sur la construction en ligne de commande du projet angulaire avec
npm install --verbose
npm run ng build
donné
src/main/frontend
src/main/webapp
maven-war-plugin + exec-maven-plugin
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.3</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<webResources>
<resource>
<directory>src/main/frontend/dist</directory>
</resource>
</webResources>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>npm-install</id>
<phase>generate-sources</phase>
<configuration>
<workingDirectory>src/main/frontend</workingDirectory>
<executable>npm</executable>
<arguments>
<argument>install</argument>
</arguments>
</configuration>
<goals>
<goal>exec</goal>
</goals>
</execution>
<execution>
<id>npm-ng-build</id>
<phase>generate-sources</phase>
<configuration>
<workingDirectory>src/main/frontend</workingDirectory>
<executable>npm</executable>
<arguments>
<argument>run</argument>
<argument>ng</argument>
<argument>build</argument>
</arguments>
</configuration>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
maven-war-plugin + maven-antrun-plugin (je n'ai pas réussi à lancer npm directement sur ma machine, d'où la construction dépendante de l'OS)
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.3</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<webResources>
<resource>
<directory>src/main/frontend/dist</directory>
</resource>
</webResources>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>exec-gen-sources</id>
<phase>generate-sources</phase>
<configuration>
<target name="Build Frontend">
<exec executable="cmd" dir="src/main/frontend" failonerror="true">
<arg line="/c npm install --verbose" />
</exec>
<exec executable="cmd" dir="src/main/frontend" failonerror="true">
<arg line="/c npm run ng build" />
</exec>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
0 votes
Je construis mon application en utilisant spring boot et nous jars pour angular2. Pour un exemple, voir github.com/Kiran-N/springboot-and-angular2
0 votes
J'ai eu une tâche similaire, voici mon approche stackoverflow.com/questions/37512154/