在Maven中结合使用Javascript和CSS文件,无需压缩,缩小等 [英] Javascript and CSS files combining in Maven build WITHOUT compression, minification etc
问题描述
是否有一个Maven插件仅结合了js和css资源,却不做任何缩小,迷惑,压缩等工作?只是简单的资源连接.
Is there an Maven plugin that just combines js and css resources but doesn't do any minification, obsucation, compressing etc? Just simple resources concatenation.
推荐答案
对项目进行以下更改:
-
在 pom.xml 中的
<dependencies>
标记中,放置:
<!-- JAVASCRIPT COMBINATION -->
<dependency>
<groupId>ro.isdc.wro4j</groupId>
<artifactId>wro4j-core</artifactId>
</dependency>
在 pom.xml 中的<plugins>
标记中,放置:
In your pom.xml, <plugins>
tag, place:
<plugin>
<groupId>ro.isdc.wro4j</groupId>
<artifactId>wro4j-maven-plugin</artifactId>
<version>1.4.3</version>
<executions>
<execution>
<phase>process-resources</phase>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<configuration>
<targetGroups>allDev</targetGroups>
<destinationFolder>${basedir}/src/main/webapp/</destinationFolder>
<contextFolder>${basedir}/src/main/webapp/</contextFolder>
</configuration>
</plugin>
在您的 pom.xml (或父 pom.xml )<dependencyManagement>
标记中,放置:
In your pom.xml (or the parent pom.xml) <dependencyManagement>
tag, place:
<!-- JAVASCRIPT COMBINATION -->
<dependency>
<groupId>ro.isdc.wro4j</groupId>
<artifactId>wro4j-core</artifactId>
<version>1.8.0</version>
</dependency>
在/project/src/main/webapp/WEB-INF
下创建 wro.xml 并放置以下内容:
Create a wro.xml under /project/src/main/webapp/WEB-INF
and place something like the following:
<?xml version="1.0" encoding="UTF-8"?>
<groups xmlns="http://www.isdc.ro/wro">
<group name="allDev">
<js minimize="false">/my1stJsFolder/*.js</js>
<js minimize="false">/my2ndJsFolder/*.js</js>
<js minimize="false">/someFileDirectlyUnderWEBINF.js</js>
</group>
</groups>
在 web.xml 中插入:
In web.xml insert:
<filter>
<filter-name>WebResourceOptimizer</filter-name>
<filter-class>ro.isdc.wro.http.WroFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>WebResourceOptimizer</filter-name>
<url-pattern>/wro/*</url-pattern>
</filter-mapping>
allDev.js 将在/project/src/main/webapp
下生成.
我不确定如何告诉wro4j仅在目标中生成一个(现在您有两个-项目源文件中一个,目标中一个).
I am not sure yet how I could tell wro4j to only generate one in target (now you have two - one in the project source files and one in target).
使用yui插件压缩时,我只能在目标中获得一个.但这对您来说不是什么大问题.
When compressing with yui plugin I only get one in target. But this should not be that big of a problem for you.
更多信息:
- https://code.google.com/p/wro4j/wiki/GettingStarted
- https://code.google.com/p/wro4j/wiki/MavenPlugin
- http://www.jarvana.com /jarvana/search?search_type = project& project = wro4j-maven-plugin
- https://code.google.com/p/wro4j/wiki/GettingStarted
- https://code.google.com/p/wro4j/wiki/MavenPlugin
- http://www.jarvana.com/jarvana/search?search_type=project&project=wro4j-maven-plugin
附加:
如果您在资源处理方面遇到任何问题,请尝试添加到<build>
标签:
If you have any problems with the resource processing try adding to <build>
tag:
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
还要<plugins>
添加
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<configuration>
<nonFilteredFileExtensions>
<nonFilteredFileExtension>pdf</nonFilteredFileExtension>
<nonFilteredFileExtension>swf</nonFilteredFileExtension>
<nonFilteredFileExtension>jpg</nonFilteredFileExtension>
<nonFilteredFileExtension>jpeg</nonFilteredFileExtension>
<nonFilteredFileExtension>class</nonFilteredFileExtension>
<nonFilteredFileExtension>jks</nonFilteredFileExtension>
<nonFilteredFileExtension>exe</nonFilteredFileExtension>
<nonFilteredFileExtension>wmv</nonFilteredFileExtension>
<nonFilteredFileExtension>jar</nonFilteredFileExtension>
<nonFilteredFileExtension>zip</nonFilteredFileExtension>
<nonFilteredFileExtension>gz</nonFilteredFileExtension>
</nonFilteredFileExtensions>
</configuration>
</plugin>
这篇关于在Maven中结合使用Javascript和CSS文件,无需压缩,缩小等的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!