在部署webapp时,我需要更新UI资源中的一些变量,解压缩一些资产并连接一些文件,目前这是通过ant任务实现的.我正在尝试使用类似的东西在maven构建过程中运行此任务...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>deploy-ui</id>
<phase>prepare-package</phase>
<inherited>false</inherited>
<configuration>
<target>
<property name="buildDir" value="${project.build.directory}/${project.build.finalName}" />
<ant antfile="build.xml" target="static-assets" />
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
上述操作失败,因为文件尚未复制到目标目录中.如果我将阶段设置为"package",则ant任务运行正常并且所有文件都被创建/修改,但是因为在运行ant目标之前已经构建了.war,所以没有任何帮助.
基本上,我需要在准备包阶段结束时运行我的蚂蚁目标.
看过生命周期参考我无法研究如何将更细粒度的目标暴露给antrun插件.
有任何想法吗?
我正在使用maven构建一个Web应用程序项目,并且打包设置为"war".我还使用YUI压缩器插件来压缩webapp目录中的javascript代码.我已经设置了YUI压缩器,如下所示:
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>yuicompressor-maven-plugin</artifactId>
<version>1.3.0</version>
<executions>
<execution>
<phase>process-resources</phase>
<goals>
<goal>compress</goal>
</goals>
</execution>
</executions>
<configuration>
<excludes>
<exclude>**/ext-2.0/**/*.js</exclude>
<exclude>**/lang/*.js</exclude>
<exclude>**/javascripts/flot/*.js</exclude>
<exclude>**/javascripts/jqplot/*.js</exclude>
</excludes>
<nosuffix>true</nosuffix>
<force>true</force>
<jswarn>false</jswarn>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
如果我这样做:mvn process-resources,src/main/webapp将被复制到target/webapp-1.0 /目录,并压缩javacripts.但是,当我运行mvn install时,所有压缩的javascripts都会被覆盖,显然打包过程会在构建war文件之前从main/webapp复制一次内容.
我怎么能绕过这个?
我是maven的新手,我正在尝试使用配置文件创建pom.xml来为不同的环境构建war文件
所以我创建了构建目标
<build>
<finalName>myacct_okc</finalName>
<resources>
<resource>
<directory>src/main/java</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
<resource>
<directory>src/main/resources</directory>
</resource>
<resource>
<directory>config/${environment}</directory>
</resource>
</resources>
</build>
Run Code Online (Sandbox Code Playgroud)
然后为每个环境创建配置文件
<profiles>
<profile>
<id>local</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<properties>
<environment>local</environment>
</properties>
</profile>
<profile>
<id>jboss</id>
<properties>
<environment>jboss</environment>
</properties>
</profile>
<profile>
<id>dev</id>
<properties>
<environment>dev</environment>
</properties>
</profile>
Run Code Online (Sandbox Code Playgroud)
我为每个env创建一个配置文件夹
project root
|-- src
| |-- main
| | |-- java
| | |-- resources
| | | |-- config.xml
| | | +-- config.properties
| | |-- webapp
| | | |-- META-INF
| | | …
Run Code Online (Sandbox Code Playgroud) 我正在编译我的项目mvn clean package
,但失败了package does not exist
.
详细命令:
target/xxxx.jar
通过mvn clean package
在源项目中运行来获取jar文件.mvn install:install-file -Dfile=lib/xxxx.jar -DgroupId=com.company -DartifactId=source-package-name -Dversion=1.0.0 -Dpackaging=jar
mvn clean package
,它刚刚失败了package does not exist
这是源项目 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>com.company</groupId>
<artifactId>source-package-name</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<name>source-package-name</name>
<description>xxxx</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.3.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal> …
Run Code Online (Sandbox Code Playgroud)