Coder Social home page Coder Social logo

samaxes / minify-maven-plugin Goto Github PK

View Code? Open in Web Editor NEW
222.0 20.0 91.0 2 MB

Combine and minimize JavaScript and CSS files for faster page loading.

Home Page: http://samaxes.github.com/minify-maven-plugin

License: Apache License 2.0

Java 84.42% CSS 5.19% JavaScript 4.31% HTML 6.07%

minify-maven-plugin's Introduction

Maven Central Build Status

Minify Maven Plugin

Minify Maven Plugin combines and minimizes your CSS and JavaScript files for faster page loading. It produces a merged and a minified version of your CSS and JavaScript resources which can be re-used across your project.

Under the hood, it uses the YUI Compressor and Google Closure Compiler but has a layer of abstraction around these tools which allows for other tools to be added in the future.

Benefits

Reduce HTTP Requests

80% of the end-user response time is spent on the front-end. Most of this time is tied up in downloading all the components in the page: images, stylesheets, scripts, etc. Reducing the number of components in turn reduces the number of HTTP requests required to render the page. This is the key to faster pages.

Combined files are a way to reduce the number of HTTP requests by combining all scripts into a single script, and similarly combining all CSS into a single stylesheet. Combining files is more challenging when the scripts and stylesheets vary from page to page, but making this part of your release process improves response times.

Compress JavaScript and CSS

Minification/compression is the practice of removing unnecessary characters from code to reduce its size thereby improving load times. A JavaScript compressor, in addition to removing comments and white-spaces, obfuscates local variables using the smallest possible variable name. This improves response time performance because the size of the downloaded file is reduced.

Usage

Configure your project's pom.xml to run the plugin during the project's build cycle.

<build>
  <plugins>
    <plugin>
      <groupId>com.samaxes.maven</groupId>
      <artifactId>minify-maven-plugin</artifactId>
      <version>1.7.6</version>
      <executions>
        <execution>
          <id>default-minify</id>
          <configuration>
            <charset>UTF-8</charset>
            <cssSourceFiles>
              <cssSourceFile>file-1.css</cssSourceFile>
              <!-- ... -->
              <cssSourceFile>file-n.css</cssSourceFile>
            </cssSourceFiles>
            <jsSourceFiles>
              <jsSourceFile>file-1.js</jsSourceFile>
              <!-- ... -->
              <jsSourceFile>file-n.js</jsSourceFile>
            </jsSourceFiles>
            <jsEngine>CLOSURE</jsEngine>
          </configuration>
          <goals>
            <goal>minify</goal>
          </goals>
        </execution>
      </executions>
    </plugin>
  </plugins>
</build>

Notice that the v1.6.X branch contains the last Java 6 compatible releases. Java 7 is required for new versions.
For more information, check the documentation or the demo applications.

License

This distribution is licensed under the terms of the Apache License, Version 2.0 (see LICENSE.txt).

minify-maven-plugin's People

Contributors

afaust avatar andreasrosdal avatar dcendents avatar dms-it avatar hboylan avatar krudolph avatar madisparn avatar mbme avatar samaxes avatar samcday avatar spodgurskiy avatar sps avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

minify-maven-plugin's Issues

[Enchancement] More flexible path configuration options

I have CSS files inside [webapp/css] and [webapp/js/themes] directories, and JS files inside [target/generated-sources/js] directory.
I need to assemble these sources into [${project.build.finalName}/css] and [${project.build.finalName}/js] directories.
I can't do this at all with the current path options.

java.lang.NullPointerException: charsetName

The 1.7.2 version of the plugin is throwing a NullPointerException if not entered the charset parameter, but it is said to be optional. Moreover, the charset parameter is not being taken into account if defined within the tag configuration, but only as user property.

Error message with debug mode off:

[INFO]
[INFO] --- maven-resources-plugin:2.5:testResources (default-testResources) @ workspace ---
[debug] execute contextualize
[INFO] Using 'ISO-8859-1' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory H:\dev\eclipse.workspace\dtp\ricardojrm\garagem\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ workspace ---
[INFO] Not compiling test sources
[INFO]
[INFO] --- maven-surefire-plugin:2.10:test (default-test) @ workspace ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- minify-maven-plugin:1.7.2:minify (default-minify) @ workspace ---
[INFO] Starting CSS task:
[INFO] Starting JavaScript task:
[INFO] Processing source file [dtp.js].
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.759s
[INFO] Finished at: Fri Feb 21 11:48:46 GMT-03:00 2014
[INFO] Final Memory: 14M/154M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.samaxes.maven:minify-maven-plugin:1.7.2:minify (default-minify) on project workspace: java.lang.NullPointerException: charsetName -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

Error message with debug mode on:

[INFO] --- minify-maven-plugin:1.7.2:minify (default-minify) @ workspace ---
[DEBUG] Using mirror public (http://www-nexus:8080/nexus/content/groups/public) for sonatype-nexus-snapshots (https://oss.sonatype.org/content/repositories/snapshots).
[DEBUG] Using mirror public (http://www-nexus:8080/nexus/content/groups/public) for sonatype-nexus-snapshots (https://oss.sonatype.org/content/repositories/snapshots).
[DEBUG] Using mirror public (http://www-nexus:8080/nexus/content/groups/public) for central (http://repo.maven.apache.org/maven2).
[DEBUG] Using mirror public (http://www-nexus:8080/nexus/content/groups/public) for central (http://repo.maven.apache.org/maven2).
[DEBUG] Using mirror public (http://www-nexus:8080/nexus/content/groups/public) for central (http://repo1.maven.org/maven2).
[DEBUG] Using mirror public (http://www-nexus:8080/nexus/content/groups/public) for caja (http://google-caja.googlecode.com/svn/maven).
[DEBUG] Using mirror public (http://www-nexus:8080/nexus/content/groups/public) for central (http://repo1.maven.org/maven2).
[DEBUG] Using mirror public (http://www-nexus:8080/nexus/content/groups/public) for caja (http://google-caja.googlecode.com/svn/maven).
[DEBUG] Using mirror public (http://www-nexus:8080/nexus/content/groups/public) for maven2-repository.dev.java.net (http://download.java.net/maven/2/).
[DEBUG] Using mirror public (http://www-nexus:8080/nexus/content/groups/public) for maven2-repository.dev.java.net (http://download.java.net/maven/2/).
[DEBUG] Using mirror public (http://www-nexus:8080/nexus/content/groups/public) for central (http://repo.maven.apache.org/maven2).
[DEBUG] Using mirror public (http://www-nexus:8080/nexus/content/groups/public) for sonatype-nexus-snapshots (https://oss.sonatype.org/content/repositories/snapshots).
[DEBUG] Using mirror public (http://www-nexus:8080/nexus/content/groups/public) for sonatype-nexus-snapshots (https://oss.sonatype.org/content/repositories/snapshots).
[DEBUG] Using mirror public (http://www-nexus:8080/nexus/content/groups/public) for central (http://repo.maven.apache.org/maven2).
[DEBUG] Using mirror public (http://www-nexus:8080/nexus/content/groups/public) for central (http://repo.maven.apache.org/maven2).
[DEBUG] com.samaxes.maven:minify-maven-plugin:jar:1.7.2:
[DEBUG] com.yahoo.platform.yui:yuicompressor:jar:2.4.7:compile
[DEBUG] rhino:js:jar:1.6R7:compile
[DEBUG] com.google.javascript:closure-compiler:jar:v20130823:compile
[DEBUG] args4j:args4j:jar:2.0.16:compile
[DEBUG] com.google.guava:guava:jar:14.0.1:compile
[DEBUG] com.google.protobuf:protobuf-java:jar:2.4.1:compile
[DEBUG] org.json:json:jar:20090211:compile
[DEBUG] com.google.code.findbugs:jsr305:jar:1.3.9:compile
[DEBUG] org.codehaus.plexus:plexus-utils:jar:1.1:runtime
[DEBUG] Created new class realm plugin>com.samaxes.maven:minify-maven-plugin:1.7.2
[DEBUG] Importing foreign packages into class realm plugin>com.samaxes.maven:minify-maven-plugin:1.7.2
[DEBUG] Imported: < maven.api
[DEBUG] Populating class realm plugin>com.samaxes.maven:minify-maven-plugin:1.7.2
[DEBUG] Included: com.samaxes.maven:minify-maven-plugin:jar:1.7.2
[DEBUG] Included: com.yahoo.platform.yui:yuicompressor:jar:2.4.7
[DEBUG] Included: rhino:js:jar:1.6R7
[DEBUG] Included: com.google.javascript:closure-compiler:jar:v20130823
[DEBUG] Included: args4j:args4j:jar:2.0.16
[DEBUG] Included: com.google.guava:guava:jar:14.0.1
[DEBUG] Included: com.google.protobuf:protobuf-java:jar:2.4.1
[DEBUG] Included: org.json:json:jar:20090211
[DEBUG] Included: com.google.code.findbugs:jsr305:jar:1.3.9
[DEBUG] Included: org.codehaus.plexus:plexus-utils:jar:1.1
[DEBUG] Configuring mojo com.samaxes.maven:minify-maven-plugin:1.7.2:minify from plugin realm ClassRealm[plugin>com.samaxes.maven:minify-maven-plugin:1.7.2, parent: sun.misc.Launcher$AppClassLoader@ba679e]
[DEBUG] Configuring mojo 'com.samaxes.maven:minify-maven-plugin:1.7.2:minify' with basic configurator -->
DEBUG bufferSize = 4096
DEBUG closureCompilationLevel = SIMPLE_OPTIMIZATIONS
DEBUG closureExterns = []
DEBUG closureLanguage = ECMASCRIPT3
DEBUG cssEngine = YUI
DEBUG cssFinalFile = style.css
DEBUG cssSourceDir = css
DEBUG cssSourceExcludes = []
DEBUG cssSourceFiles = []
DEBUG cssSourceIncludes = []
DEBUG jsEngine = CLOSURE
DEBUG jsFinalFile = pack.js
DEBUG jsSourceDir = js
DEBUG jsSourceExcludes = []
DEBUG jsSourceFiles = [dtp.js]
DEBUG jsSourceIncludes = []
DEBUG nosuffix = false
DEBUG skipMerge = false
DEBUG skipMinify = false
DEBUG suffix = min
DEBUG verbose = false
DEBUG webappSourceDir = H:\dev\eclipse.workspace\dtp\ricardojrm\garagem/src/main/webapp
DEBUG webappTargetDir = H:\dev\eclipse.workspace\dtp\ricardojrm\garagem\target/workspace-0.0.1-SNAPSHOT
DEBUG yuiDisableOptimizations = false
DEBUG yuiLinebreak = -1
DEBUG yuiMunge = true
DEBUG yuiPreserveAllSemiColons = false
[DEBUG] -- end configuration --
[DEBUG] Adding source file [dtp.js].
[INFO] Starting CSS task:
[INFO] Starting JavaScript task:
[INFO] Processing source file [dtp.js].
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.863s
[INFO] Finished at: Fri Feb 21 12:11:33 GMT-03:00 2014
[INFO] Final Memory: 15M/155M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.samaxes.maven:minify-maven-plugin:1.7.2:minify (default-minify) on project workspace: java.lang.NullPointerException: charsetName -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.samaxes.maven:minify-maven-plugin:1.7.2:minify (default-minify) on project workspace: java.lang.NullPointerException: charsetName
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:213)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: org.apache.maven.plugin.MojoFailureException: java.lang.NullPointerException: charsetName
at com.samaxes.maven.minify.plugin.MinifyMojo.execute(MinifyMojo.java:414)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
... 19 more
Caused by: java.util.concurrent.ExecutionException: java.lang.NullPointerException: charsetName
at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:252)
at java.util.concurrent.FutureTask.get(FutureTask.java:111)
at com.samaxes.maven.minify.plugin.MinifyMojo.execute(MinifyMojo.java:412)
... 21 more
Caused by: java.lang.NullPointerException: charsetName
at java.io.InputStreamReader.(InputStreamReader.java:99)
at com.samaxes.maven.minify.plugin.ProcessFilesTask.merge(ProcessFilesTask.java:202)
at com.samaxes.maven.minify.plugin.ProcessFilesTask.call(ProcessFilesTask.java:173)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:722)
[ERROR]
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

Why do I get a warning that "The source file [...] has the same name as the final file"?

I want to take my source file, foo.js, and use minify-maven-plugin to produce a minified version of this file called foo.min.js.

It appears that minify-maven-plugin does some magic to auto-change the extension from .js to .min.js, so I should set the jsFinalFile to app.js in order to get a target file called app.min.js. (This behavior IMO is undesirable; the jsFinalFile should really be final file name, and minify-maven-plugin shouldn't touch it.)

So my config looks like:

<execution>
    <id>minify-foo-js</id>
    <goals>
        <goal>minify</goal>
    </goals>
    <configuration>
        <jsEngine>CLOSURE</jsEngine>
        <jsSourceFiles>
            <jsSourceFile>foo.js</jsSourceFile>
        </jsSourceFiles>
        <jsFinalFile>foo.js</jsFinalFile>
    </configuration>
</execution>

When compiling this, I get a warning:

[INFO] --- minify-maven-plugin:1.7.2:minify (minify-foo-js) @ exampleproject ---
[WARNING] The source file [foo.js] has the same name as the final file.

If instead I set jsFinalFile to foo.min.js, I get an output file called foo.min.min.js, which is not what I want.

Why is this a warning; what undesirable effects could arise? And why does minify-maven-plugin change the extension of jsFinalFile from the one that I ask for?

[Enchancement] Consider parsing HTML for CSS and JavaScript source files

Consider adding support for HTML parsing similarly to usemin Grunt plugin:

<!-- build:<type>(alternate search path) <path> -->
... HTML Markup, list of script / link tags.
<!-- endbuild -->

Example:

<!-- build:js js/script.js -->
<script src="js/app.js"></script>
<script src="js/controllers/thing-controller.js"></script>
<script src="js/models/thing-model.js"></script>
<script src="js/views/thing-view.js"></script>
<!-- endbuild -->

css minification fails for base64 encoded background images

The css minification will fail producing a 0 bytes .min css file when there is a css rule that defines a background image using a base64 encoded image.
Note that it is not related to the "background" declaration itself but to the length of the line. In my case:

.foo {
background:transparent url('data:image/gif;base64,R0lS__ANOTHER_3000_CHARACTERS_HERE__wIADs=') no-repeat 0 0;
}

will fail.

If I run the compressor using the .jar, the minification will succeed.

Allow jsSourceDir (an the likes) to refer to the project root.

First of all, thx for this plugin - after almost a day of search for a maven plugin that minimizes and combines js files, I finally found a plugin that is (a) pretty well documented and (b) actually works ;)

However, I noticed that the jsSourceDir arguments are interpreted relative to ${basedir}/src/main/webapp*, and it seems there is no way to use e.g. ${basedir}/src/main/javascript or ${basedir}/src/main/resource/javascript as the source folder.

I suggest to add support for this; for my project I hacked some symlinks as a workaround, but would like to get rid of them.

*Another issue here is, that this path does not show up in the maven output in the latest version from the git of today. - If I hadn't tried out an older version first (I think 1.3.5), where this path shows up, I would have hardly figured out where the plugin looks for files by default.

Cheers,
Claus

Delete intermediate files

Hi,

when I'm packaging my war, I got script.js AND script.min.js; same problem for css files.

How to get rid of script.js and style.css after minification ?

M2E connector

Implement a m2e connector for Minify Maven Plugin that will execute minify on Eclipse incremental builds, if a change is detected on CSS or JavaScript resources.

.tmp files packed with minified versions to WAR

A merged .tmp files are being brought to WAR after minifying.

For example my configuration as follows:

<execution>
    <id>client-js-minify</id>
    <phase>process-resources</phase>
    <configuration>
        <charset>utf-8</charset>
        <jsEngine>yui</jsEngine>
        <jsSourceDir>static/js</jsSourceDir>
        <jsSourceFiles>
            <jsSourceFile>modules/commons/Console.js</jsSourceFile>
...
            <jsSourceFile>client.js</jsSourceFile>
        </jsSourceFiles>
        <nosuffix>true</nosuffix>   
        <jsFinalFile>client-min.js</jsFinalFile>
    </configuration>
    <goals>
        <goal>minify</goal>
    </goals>
</execution>

in this case client-min.js.tmp was packed to WAR file thogether with clinet-min.js

Maven: Eclipse Build in Maven 3.0.4/1.4.0.20130531-2315

Custom compiler flags

It would be beneficial to allow the user to specify compiler flags for the Closure Compiler.

My team wants to use the @ngInject annotation that the compiler supports, but unfortunately you must use the flag --angular_pass to take advantage of that feature.

Build error using Maven 2.2.1

Hi there,

First off, thank you very much for this plugin!

Now on with the issue. For legacy purposes we have to build our projects with Maven 2.2.1. When using your minify plugin (version 1.7.2), we try to minify our javascript source. Unfortunately this results in the following error:

[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Failed to configure plugin parameters for: com.samaxes.maven:minify-maven-plugin:1.7.2

on the command line, specify: '-DclosureCompilationLevel=VALUE'

Cause: Cannot assign configuration entry 'closureCompilationLevel' to 'class com.google.javascript.jscomp.CompilationLevel' from '${closureCompilationLevel}', w
hich is of type class java.lang.String

When using version 1.7.1 no build error occurs.

Kind regards,
Allon

config file for execution

Previous versions allowed for configuration files to be used. So that you could split executions out and not push everything into the POM file. Having this feature would be really nice.

Minified JS files not packaged in JAR

I'm using minify-maven-plugin in a JAR packaged maven project. The output JS files are getting generated in the target folder, but they are not included as part of the JAR packaging.
If I used the plugin in a WAR project, it works fine.

Fail Build on Missing File

We were just bitten by this issue--a typo in a file name in caused our minified file not to have everything it needed. While the plugin did emit an appropriate warning, maven when on to blithly report BUILD SUCCESS. It would be nice if the plug-in could be configured to fail the maven build process in this circumstance.

This may not make any sense in all circumstances or when using patterns to include/exclude files, but even then it may. If a pattern matches no files why is the pattern there? However I feel it is definitely something that would be useful in certain circumstances, like ours.

js not recognized as js?

Hi,

I just used your plugin but it does not work as expected. Here is my configuration:
DEBUG bufferSize = 4096
DEBUG charset = UTF-8
DEBUG closureCompilationLevel = SIMPLE_OPTIMIZATIONS
DEBUG closureExterns = []
DEBUG closureLanguage = ECMASCRIPT3
DEBUG cssEngine = YUI
DEBUG cssFinalFile = style.css
DEBUG cssSourceDir = static
DEBUG cssSourceExcludes = []
DEBUG cssSourceFiles = []
DEBUG cssSourceIncludes = [js/app.js]
DEBUG jsEngine = YUI
DEBUG jsFinalFile = app.min.js
DEBUG jsSourceDir = static
DEBUG jsSourceExcludes = []
DEBUG jsSourceFiles = []
DEBUG jsSourceIncludes = [js/app.js]
DEBUG jsTargetDir = C:\Users\Stefan\Programmierung\eclipse\workspace\crm\target
DEBUG nosuffix = false
DEBUG skipMerge = false
DEBUG skipMinify = false
DEBUG suffix = min
DEBUG verbose = true
DEBUG webappSourceDir = C:\Users\Stefan\Programmierung\eclipse\workspace\crm/src/main/webapp
DEBUG webappTargetDir = C:\Users\Stefan\Programmierung\eclipse\workspace\crm\target/crm-0.0.1-SNAPSHOT
DEBUG yuiDisableOptimizations = false
DEBUG yuiLinebreak = -1
DEBUG yuiMunge = true
DEBUG yuiPreserveAllSemiColons = false
[DEBUG] -- end configuration --
[DEBUG] Adding source file [C:\Users\Stefan\Programmierung\eclipse\workspace\crm\src\main\webapp\static\js\app.js].
[DEBUG] Adding source file [C:\Users\Stefan\Programmierung\eclipse\workspace\crm\src\main\webapp\static\js\app.js].
[INFO] Starting JavaScript task:
[ERROR] No valid JavaScript source files found to process.
[INFO] Starting CSS task:
[INFO] Processing source file [C:\Users\Stefan\Programmierung\eclipse\workspace\crm\src\main\webapp\static\js\app.js].
[INFO] Creating the merged file [C:\Users\Stefan\Programmierung\eclipse\workspace\crm\target\crm-0.0.1-SNAPSHOT\static\style.css].
[INFO] Creating the minified file [C:\Users\Stefan\Programmierung\eclipse\workspace\crm\target\crm-0.0.1-SNAPSHOT\static\style.min.css].
[DEBUG] Using YUI Compressor engine.
[INFO] Uncompressed size: 1055 bytes.
[INFO] Compressed size: 875 bytes minified (474 bytes gzipped).
[INFO]

As you can see, I add a .js file to both the js source files list AND the css source files list. When executing the JS task it breaks, complaining no valid js source files are provided. On the other hand, the CSS tasks processes the JS file.
This seems awkward to me. Looking at the source code didn't help me so far - it seems to look good. Any ideas?
I use version 1.7.2

Thanks
Stefan

Option to use same subdirectory on target as in source

It would be nice if, when skipMerge is true, there would be an option to write the minified file in the same subdirectory as the source file (without having to specify each directory in a separate execution, which gets cumbersome when there are many directories).

The idea is to set the jsSourceDir and jsTargetDir to equivalent parent directories, and having a jsSourceInclude of */.js (or something similar), and then having the plugin find all those files under the source, and create an equivalent directory structure on the target.

(In my case, I didn't have too many directories yet, and this plugin is perfect otherwise, so the one-execution-per-dir solution still works for me. Still would be nice to have the option, though.)

Better concurrency

Removed shared properties between threads for a better concurrency model.

Do not fail build when base dir does not exist - just skip execution

Why:
We use a corporate parent pom for most of the packaging config for the plugins. Pom's for projects ears, wars, jars, etc all just inherit from it and are responsible for what dependencies are used.

Rather than ask 100+ projects to go through and add a snipit to the each module that has css / js in it, I'd rather keep that config in the corporate pom.

What:
I'd like it changed so that if the directory doesn't exist, it just logs a message like "default-minify: baseDir 'c:/workspace/myProject/src/main/webapp/' does not exist. Skipping compression".

eclipse incremental build support

I want eclipse execute minify plugin auto & incremental. So I add following config:

<pluginExecution>
    <pluginExecutionFilter>
        <groupId>com.samaxes.maven</groupId>
        <artifactId>minify-maven-plugin</artifactId>
        <versionRange>[1.7.2,)</versionRange>
        <goals>
            <goal>minify</goal>
        </goals>
    </pluginExecutionFilter>
    <action>
        <execute>
            <runOnIncremental>true</runOnIncremental>
        </execute>
    </action>
</pluginExecution>

It works, but when I save a file, even not a .js or .css file, then all minify execute again(It takes a long time. During the time, eclipse always show "Build workspace (xx%)").

So I want minify-maven-plugin support incremental build. If a files are not changed and the min files exist, then skip the excution.

I am using lesscss-maven-plugin too, it works fine, then source code is here(https://github.com/marceloverdijk/lesscss-maven-plugin/blob/master/src/main/java/org/lesscss/mojo/CompileMojo.java).

Thanks very much.

Run the plugin based on pom profile

Olá Samuel, how are you?

I'm configuring a project using this plugin and I have the following question: if you have two pom environment profiles (dev and production), how am I able to use all the split files in development and the minified and aggregated single file in production? Something like Sprockets in Ruby. Have you considered that in the plugin's implementation?

What I did realize was the split files are deleted from the target war, which is good for deploying in production. What would you suggest?

Obrigado!

Zé Mota

Producing 0 size files when found WARNING in js

Using closure minifying with optimization, plugin produces 0-length files as output when warnings found:

WARNING: 0 error(s), 13 warning(s)
[INFO] Uncompressed size: 3138 bytes.
[INFO] Compressed size: 0 bytes minified (20 bytes gzipped).

Source paths are always relative

Hi there,

Looks like a great plugin... however, I couldn't get it to pick up the source files... after finding the <verbose> and <nosuffix> options, I then discovered it always treats paths as relative to the normal location, e.g.
cssSourceDir = ${basedir}/src/main/webapp/css
cssTargetDir = ${basedir}/target//css

So even if I set cssSourceDir to ${basedir}/...path... it would end up using ${basedir}/src/main/webapp/css/${basedir}/...path...

Might be worthwhile adding something to the documentation to make it a bit clearer if you have a chance.

Best regards, Nigel

SourceFiles with Wildcards

Hey ya :)

First Thanks for this project. (y)
Its not possible to define some Source Files with Wildcards, correct?
In my Project Ive about 300 js/css Files to minimize and wildcards would be a easier use here.
A recusive DirScanner that may handles configs like that:

                        <!-- absolute order -->
                        <cssSourceFile>moduleA/file-1.css</cssSourceFile>
                        <cssSourceFile>moduleA/file-2.css</cssSourceFile>
                        <cssSourceFile>moduleA/file-4.css</cssSourceFile>
                        <cssSourceFile>moduleA/file-3.css</cssSourceFile>
                        <cssSourceFile>moduleA/file-8.css</cssSourceFile>
                        <cssSourceFile>moduleA/file-n.css</cssSourceFile>

                        <!-- whole folder by alphabetical order -->
                        <cssSourceFile>moduleB/*.css</cssSourceFile>

Option to skip minify step

Some libraries only have minified versions available for download.
In these cases only the merge step is required.

Allow for Control of File Consolidation Order

Often, Javascript source code will refer to libraries defined in other source files. It seems that currently the filenames are being sorted alphabetically before the files are consolidated together. It would be very helpful if the order of the files specified in the jsSourceFiles element of the POM were preserved, to control for these dependencies.

For instance, if I have a file 'cart.js' which uses jQuery code defined in 'jquery-1.9.0.js', consolidating the files will result in the cart.js file appearing first, and referring to a jQuery object that has not yet been defined.

Preserve sub-directory structure when only minifying

As stated in an after-fix comment on #17 a minification without merging (skipMerge = true) currently removes any subdirectory structure captured by jsSourceIncludes / cssSourceIncludes which can be very problematic for projects relying on that sub-directory structure.

From the after-fix comment:

For example, when jsSourceDir="js and jsSourceInclude="*/.js
minifying: /src/main/webapp/js/some/path/a.js
creates: /target//webapp/js/a.min.js
I think it could have been more convenient if the result were created at: /target//webapp/js/some/path/a.min.js

Issue in merging java-script source files in a particular order

I found problem with minified merged javascript files at run time. The variable used by second js file is declared and defined in first file, but after concatenation of the files, it doesn't come with optimal result.

I am using backbone js, the files which needed are --

  1. model.js (containing all Backbone model objects)
  2. collection.js (containing all Backbone collection objects)
  3. view.js (containg all Backbone View objects)
    Here is the requirement is to concatenate none of other order than model+collection+view.

This maven plugin is using java.util.ArrayList to store these source files, and unfortunately It complies alphabetical order for storing files on file's name and at merging time it consequences an order of merging is collection+model+view, resulting a scrap final file. refered docs (http://samaxes.github.io/minify-maven-plugin/minify-mojo.html).

Its better to provide more control over the file name specified with order of merging at maven execution-configuration e.g.

<configuration>
...
<jsSourceDir>resources/js/src</jsSourceDir>
<jsSourceIncludes>
<jsSourceInclude>
<file>/c.js</file>
<order>3</order>
</jsSourceInclude>
<jsSourceInclude>
<file>
/a.js</file>
<order>1</order>
</jsSourceInclude>
<jsSourceInclude>
<file>**/b.js</file>
<order>2</order>
</jsSourceInclude>
</jsSourceIncludes>
....
</configuration>

This makes the plugin more flexible and better control over the merging of files, and moreover the programmer will be able to follow the file naming convention over development time.

[BUILD ERROR] specify: '-DclosureCompilationLevel=VALUE'

Hi, i just wanted to use your maven plugin to minify css files into one, but i always get the following error:

[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Failed to configure plugin parameters for: com.samaxes.maven:minify-maven-plugin:1.7.2

on the command line, specify: '-DclosureCompilationLevel=VALUE'

Cause: Cannot assign configuration entry 'closureCompilationLevel' to 'class com.google.javascript.jscomp.CompilationLevel' from '${closureCompilationLevel}', which is of type class java.lang.String


Specifying the closureCompilationLevel does not solve this error.
I use Maven 2.2.1 and Java 7.

Maybe you could give me a hint how to solve this problem. Thanks in advance!


[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.lifecycle.LifecycleExecutionException: Error configuring: com.samaxes.maven:minify-maven-plugin. Reason: Unable to parse the created DOM for plugin configuration
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:723)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:535)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.plugin.PluginConfigurationException: Error configuring: com.samaxes.maven:minify-maven-plugin. Reason: Unable to parse the created DOM for plugin configuration
at org.apache.maven.plugin.DefaultPluginManager.populatePluginFields(DefaultPluginManager.java:1363)
at org.apache.maven.plugin.DefaultPluginManager.getConfiguredMojo(DefaultPluginManager.java:724)
at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:468)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
... 17 more
Caused by: org.codehaus.plexus.component.configurator.ComponentConfigurationException: Cannot assign configuration entry 'closureCompilationLevel' to 'class com.google.javascript.jscomp.CompilationLevel' from '${closureCompilationLevel}', which is of type class java.lang.String
at org.codehaus.plexus.component.configurator.converters.AbstractConfigurationConverter.fromExpression(AbstractConfigurationConverter.java:149)
at org.codehaus.plexus.component.configurator.converters.composite.ObjectWithFieldsConverter.fromConfiguration(ObjectWithFieldsConverter.java:80)
at org.codehaus.plexus.component.configurator.converters.ComponentValueSetter.configure(ComponentValueSetter.java:247)
at org.codehaus.plexus.component.configurator.converters.composite.ObjectWithFieldsConverter.processConfiguration(ObjectWithFieldsConverter.java:137)
at org.codehaus.plexus.component.configurator.BasicComponentConfigurator.configureComponent(BasicComponentConfigurator.java:56)
at org.apache.maven.plugin.DefaultPluginManager.populatePluginFields(DefaultPluginManager.java:1357)
... 20 more

Option to not include the source location comment

Would it be possible to include an option to allow source map generation but not add the comment to the end of the minified JS.
This would allow for people who want to use the HTTP header to send the source map location, or possibly conditionally include the comment or header.

Thanks, Scott.

nosuffix in 1.7, but not in 1.6?

I see the nosuffix property is in "since 1.7." It's probably safe to guess that it's not in 1.6.x. Okay. What about a suffix property of empty string, e.g.,

<suffix></suffix>

Will that work--I'll be testing it-- but wanted to ask.

Documentation: missing information about file order

When CSS file are merged into one file, order of files can be very important. There is no info in documentation that order of files defined in tag cssSourceFiles is preserved but order of files defined in cssSourceIncludes is not preserverd because files are sorted.

Moroever, file from cssSourceIncludes are merged after files from cssSourceFiles, even if those tag has opposite order in plugin configuration.

I think rules for file ordering should be clearly described in documentation.

(I had to analyze source code before I get what I wanted)

Option to skip merge step

For applications using Asynchronous Module Definition (AMD) API, e.g. RequireJS, for JavaScript modules, only the minification of each individual file is useful.

doc: yuiMunge

http://samaxes.github.io/minify-maven-plugin/minify-mojo.html#yuiMunge says:

Minify only. Do not obfuscate local symbols.

http://yui.github.io/yuicompressor/#using says:

--nomunge
Minify only. Do not obfuscate local symbols.

Is there a mismatch between the maven-plugin option name and what it does (i.e., yuiMunge doesn't munge)? Or is the description backwards?

If it's the former, can you deprecate the option and create yuiNoMunge or yuiObfuscate?

If it's the latter, can you reverse the description?

External file for source files

It would be nice to be able to configure source files in an external file(s). Then there would only be one place to define scripts/css sources for deployment and development as the same file(s) could be used for rendering separate unminified script/css-link tags into pages for development with a configuration switch for minified bundle. For example

src/xxx/js-bundle.txt:

/js/lib/jquery.js
/js/script1.js
/js/script2.js

pom.xml:

<plugin>...minify-maven-plugin...
<configuration>
<jsSourcesFile>src/xxx/js-bundle.txt</jsSourcesFile>
...

and then in template:

if optimizeResources
  <script src="js/js-bundle.js"/>
else
  foreach script in load("src/xxx/js-bundle.txt").splitByNewLine() do
   <script src="$script"/>
end

With current configuration options one must define source files in two places (in template and pom) to achieve this recurring use case.

auto-compress when the source file changes

Hi,
Can you add support where I make change in source files, and plugin should automatically compress it to final file?

Why I need this feature ?
I have changed my html files to use final compressed files only.

When I am testing locally, I need to see my changes instantly whenever I make change in actual source files.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.