samaxes / minify-maven-plugin

Combine and minimize JavaScript and CSS files for faster page loading.
http://samaxes.github.com/minify-maven-plugin
Apache License 2.0
222 stars 91 forks source link

minify-maven-plugin 1.7.6 does not exclude directory files #167

Closed Dzeg closed 5 years ago

Dzeg commented 5 years ago

Im working with an AEM multi-module project that already have minify-maven-plugin 1.7.6, which do a fantastic job.

Currently Im doing a POC adding webpack + reactjs to the current project and Im trying to exclude some directories to the minify-maven-plugin. The idea is to have webpack to handle all this minification tasks at the end, but that migration will take time. So, I need to have minify-maven-plugin until we can move to webpack completely.

What I would like to exclude are all the CSS and JS files in any module project that are inside of the below directories:

I do have this configuration:

<build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>com.samaxes.maven</groupId>
                    <artifactId>minify-maven-plugin</artifactId>
                    <version>1.7.6</version>
                    <executions>
                        <execution>
                            <id>default-minify</id>
                            <goals>
                                <goal>minify</goal>
                            </goals>
                            <configuration>
                                <verbose>true</verbose>
                                <skipMerge>true</skipMerge>
                                <nosuffix>true</nosuffix>
                                <webappSourceDir>${basedir}/src/main/content/jcr_root</webappSourceDir>
                                <webappTargetDir>${project.build.directory}/classes</webappTargetDir>
                                <cssSourceDir>.</cssSourceDir>
                                <jsSourceDir>.</jsSourceDir>
                                <!-- CSS Excludes -->
                                <cssSourceExcludes>
                                    <cssSourceExclude>**/*.min.css</cssSourceExclude>
                                </cssSourceExcludes>
                                <cssSourceExcludes>
                                    <cssSourceExclude>**/*.scss</cssSourceExclude>
                                </cssSourceExcludes>
                                <cssSourceExcludes>
                                    <cssSourceExclude>clientlib-global/*.css</cssSourceExclude>
                                </cssSourceExcludes>
                                <cssSourceExcludes>
                                    <cssSourceExclude>**/clientlib-brand/*.css</cssSourceExclude>
                                </cssSourceExcludes>
                                <cssSourceExcludes>
                                    <cssSourceExclude>**/clientlib-utils/*.css</cssSourceExclude>
                                </cssSourceExcludes>
                                <cssSourceExcludes>
                                    <cssSourceExclude>**/react-component/*.css</cssSourceExclude>
                                </cssSourceExcludes>
                                <!-- JS Excludes -->
                                <jsSourceExcludes>
                                    <jsSourceExclude>**/*.min.js</jsSourceExclude>
                                </jsSourceExcludes>
                                <jsSourceExcludes>
                                    <jsSourceExclude>gulpfile.js</jsSourceExclude>
                                </jsSourceExcludes>
                                <jsSourceExcludes>
                                    <jsSourceExclude>webpack.config.js</jsSourceExclude>
                                </jsSourceExcludes>
                                <jsSourceExcludes>
                                    <jsSourceExclude>clientlib-global/*.js</jsSourceExclude>
                                </jsSourceExcludes>
                                <jsSourceExcludes>
                                    <jsSourceExclude>**/clientlib-brand/*.js</jsSourceExclude>
                                </jsSourceExcludes>
                                <jsSourceExcludes>
                                    <jsSourceExclude>**/clientlib-utils/*.js</jsSourceExclude>
                                </jsSourceExcludes>
                                <jsSourceExcludes>
                                    <jsSourceExclude>**/react-component/*.js</jsSourceExclude>
                                </jsSourceExcludes>
                                <!-- Incluedes -->
                                <cssSourceIncludes>
                                    <cssSourceInclude>**/*.css</cssSourceInclude>
                                </cssSourceIncludes>
                                <jsSourceIncludes>
                                    <jsSourceInclude>**/*.js</jsSourceInclude>
                                </jsSourceIncludes>
                                <jsEngine>CLOSURE</jsEngine>                                 
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
................

But Im getting this error:

[INFO] Compressed size: 0 bytes minified (20 bytes gzipped).
[INFO] Creating the minified file [/home/dzeg/dzegdev/xxxxx/xxxx-aem-6.3/aem-diabetes-patient-common/aem-diabetes-patient-common-ui/target/classes/./etc/designs/diabetes-patient-clientlibs/common/clientlibs/clientlib-brand/index.js].
Feb 15, 2019 2:41:36 PM com.google.javascript.jscomp.LoggerErrorManager println
WARNING: WARNING - Failed to load module "global/sass/index.scss.js"

Feb 15, 2019 2:41:36 PM com.google.javascript.jscomp.LoggerErrorManager println
SEVERE: index.js:1: ERROR - required "module$global$sass$index_scss" namespace never provided
import 'global/sass/index.scss';
^

Running it with -X:

[ERROR] Failed to execute goal com.samaxes.maven:minify-maven-plugin:1.7.6:minify (default-minify) on project aem-diabetes-patient-common-ui: java.lang.RuntimeException: JSCompiler errors
[ERROR] index.js:1: ERROR - required "module$global$sass$index_scss" namespace never provided
[ERROR] import 'global/sass/index.scss';
[ERROR] ^
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.samaxes.maven:minify-maven-plugin:1.7.6:minify (default-minify) on project aem-diabetes-patient-common-ui: java.lang.RuntimeException: JSCompiler errors
index.js:1: ERROR - required "module$global$sass$index_scss" namespace never provided
import 'global/sass/index.scss';
^

    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
    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:116)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoExecutionException: java.lang.RuntimeException: JSCompiler errors
index.js:1: ERROR - required "module$global$sass$index_scss" namespace never provided
import 'global/sass/index.scss';
^

    at com.samaxes.maven.minify.plugin.MinifyMojo.execute(MinifyMojo.java:516)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
    ... 20 more
Caused by: java.util.concurrent.ExecutionException: java.lang.RuntimeException: JSCompiler errors
index.js:1: ERROR - required "module$global$sass$index_scss" namespace never provided
import 'global/sass/index.scss';
^

    at java.util.concurrent.FutureTask.report(FutureTask.java:122)
    at java.util.concurrent.FutureTask.get(FutureTask.java:192)
    at com.samaxes.maven.minify.plugin.MinifyMojo.execute(MinifyMojo.java:514)
    ... 22 more
Caused by: java.lang.RuntimeException: JSCompiler errors
index.js:1: ERROR - required "module$global$sass$index_scss" namespace never provided
import 'global/sass/index.scss';
^

    at com.samaxes.maven.minify.plugin.ProcessJSFilesTask.minify(ProcessJSFilesTask.java:147)
    at com.samaxes.maven.minify.plugin.ProcessFilesTask.call(ProcessFilesTask.java:164)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
[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/MojoExecutionException

Notice that even that I tried to exclude the directory clientlib-brand using: <jsSourceExclude>**/clientlib-brand/*.js</jsSourceExclude> the plugin keeps trying to minify it:
aem-diabetes-patient-common/aem-diabetes-patient-common-ui/target/classes/./etc/designs/diabetes-patient-clientlibs/common/clientlibs/clientlib-brand/index.js].

I tried many things like change the phase and exclude explicitly the file but Im still not able to make it work. If someone of you can give me a help Ill really appreciate it..

Thanks beforehand

Dzeg commented 5 years ago

I found my issue... child pom was affecting me...Closing...