Skip to content
This repository has been archived by the owner on Nov 29, 2018. It is now read-only.

Plugin takes this long to build #73

Open
dbclkclk opened this issue Mar 16, 2015 · 13 comments
Open

Plugin takes this long to build #73

dbclkclk opened this issue Mar 16, 2015 · 13 comments

Comments

@dbclkclk
Copy link

Hey question:

Why does maven grunt takes this long to build (4 hrs):

 Reading C:\Users\User\git\XXXXXX\XXXXXX\target-grunt\dist\test\services\ServiceSpec.js...OK
 Writing C:\Users\User\git\XXXXXX\XXXXXX\target\XXXXXX-frontend\resources\js\test\services\ServiceSpec.js...OK

 Done, without errors.
 [INFO] 
  [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ XXXXXX-frontend ---
 [INFO] Using 'UTF-8' encoding to copy filtered resources.
 [INFO] skip non existing resourceDirectory C:\Users\User\git\XXXXXX\XXXXXX\src\test\resources
 [INFO] 
 [INFO] --- maven-compiler-plugin:3.0:testCompile (default-testCompile) @ XXXXXX-frontend ---
 [INFO] No sources to compile
 [INFO] 
 [INFO] --- maven-surefire-plugin:2.16:test (default-test) @ XXXXXX-frontend ---
 [INFO] No tests to run.
 [INFO] 
 [INFO] --- maven-antrun-plugin:1.1:run (default) @ XXXXXX-frontend ---
 [INFO] Executing tasks
 [echo] Using Dev environment
 [INFO] Executed tasks
 [INFO] 
 [INFO] --- maven-war-plugin:2.3:war (default-war) @ XXXXXX-frontend ---
 [INFO] Packaging webapp
 [INFO] Assembling webapp [XXXXXX-frontend] in     [C:\Users\User\git\XXXXXX\XXXXXX\target\XXXXXX-frontend]
 [INFO] Processing war project
 [INFO] Copying webapp resources [C:\Users\User\git\XXXXXX\XXXXXX\src\main\webapp]
 [INFO] Webapp assembled in [27556 msecs]
 [INFO] Building war: C:\Users\User\git\XXXXXX\XXXXXX\target\XXXXXX-frontend.war
 [INFO] 
 [INFO] --- maven-dependency-plugin:2.3:copy (default) @ XXXXXX-frontend ---
 [INFO] Configured Artifact: org.mortbay.jetty:jetty-runner:7.4.5.v20110725:jar
 [INFO] org.mortbay.jetty:jetty-runner:7.4.5.v20110725:jar already exists in   C:\Users\User\git\XXXXXX\XXXXXX\target\dependency
 [INFO] ------------------------------------------------------------------------
 [INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 04:36 h
[INFO] Finished at: 2015-03-16T05:36:39-04:00
[INFO] Final Memory: 14M/155M
[INFO] ------------------------------------------------------------------------

 Process finished with exit code 0
@dbclkclk dbclkclk changed the title Take this long to build Plugin takes this long to build Mar 16, 2015
@adamdubiel
Copy link
Collaborator

Oh wow, never seen anything like this, do you have any custom tasks? If you run grunt from targe-tgrunt, does it also take so long to finish?

@dbclkclk
Copy link
Author

@adamdubiel no custom tasks. From the image, for the most part it's basically just stuck there until it starts copying in the target-grunt folder. The actual command you want me to run is mvn target-grunt ?

image

@dbclkclk
Copy link
Author

Also, this is my grunt file:

 module.exports = function(grunt){

  grunt.initConfig({

  gruntMavenProperties: grunt.file.readJSON('grunt-maven.json'),
   bgShell:{
      fail:true,
      npm_install:{
        cmd:'npm install'
      },
      bower_install:{
        cmd:'bower install'
      }
    },

  mavenPrepare: {
      options: {
          resources: ["**"]
      },
      prepare: {}
  },

  mavenDist: {
          options: {
              warName: 'cointraders-frontend',
              deliverables: ['**', '!non-deliverable.js'],
              gruntDistDir: 'dist'
          },
          dev: {
              warName: 'war-dev'
          }
  },

  karma: {
      web: {
        configFile:'karma/karma.conf.js'
      },
      web_ci:{
        options:{
          singleRun:true,
          watch:false
        },
        configFile:'karma/karma.conf.js'
      }
  },

  jshint: {
      all:{
        options: {
          jshintrc: true
        },
        files: {
          src: [
            'app/**/*.js','app/*.js',
            'controllers/**/*.js','controllers/*.js',
            'services/**/*.js','services/*.js',
            'directives/**/*.js','directives/*.js'
            ]
        }
      }
  },

  watch:{
      maven: {
          files: ['<%= gruntMavenProperties.filesToWatch %>'],
          tasks: 'default'
      }
  },

  concurrent:{
      options: {
        logConcurrentOutput: true
      },
      test:['karma:web_ci','jshint:all']
  },

  cssmin: {
      core: {
        expand: true,
        cwd: '../css/',
        src: ['*.css', '!*.min.css'],
        dest: 'mcss/dist',
        ext: '.min.css'
      }
  },

  uglify: {
      core: {
        options: {
          mangle: false
        },
        files: [{
          expand: true,
          src: [
            'app/**/*.js','app/*.js',
            'controllers/**/*.js','controllers/*.js',
            'services/**/*.js','services/*.js',
            'directives/**/*.js','directives/*.js'
            //,'test/**/**/*.js', 'test/**/*.js','test/*.js'
            ],
          dest: 'ujs/dist/',
          ext: '.min.js'
        }]
      }
  },

  concat:{
      js: {
        options: {
          // Replace all 'use strict' statements in the code with a single one at the top
          banner: "'use strict';\n",
          process: function(src, filepath) {
            return '// Source: ' + filepath + '\n' +
            src.replace(/(^|\n)[ \t]*('use strict'|"use strict");?\s*/g, '$1');
          }
        },
        src: ['ujs/dist/**/*.min.js'],
        dest: 'ujs/dist/index.min.js'
      },
      css: {
        src: ['mcss/dist/**/*.min.css'],
        dest: 'mcss/dist/app.min.css'
      }
  },


  lifecycle: {
      validate: [
      'jshint'
      ],
      test: [
      'bgShell:npm_install',
      'bgShell:bower_install',
      'karma:web_ci'
      ],
      package: [
      'cssmin',
      'uglify',
      'concat'
      ]
    }
  });

   grunt.loadNpmTasks('grunt-contrib-watch');
   grunt.loadNpmTasks('grunt-concurrent');
    grunt.loadNpmTasks('grunt-karma');
    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-contrib-cssmin');
    grunt.loadNpmTasks('grunt-contrib-concat');
    grunt.loadNpmTasks('grunt-build-lifecycle');
    grunt.loadNpmTasks('grunt-bg-shell');
     grunt.loadNpmTasks('grunt-maven');

     grunt.registerTask('qa',['mavenPrepare','mavenDist']);
     grunt.registerTask('ci',['mavenPrepare','concurrent','mavenDist']);
     grunt.registerTask('default', ['mavenPrepare','concurrent','mavenDist']);


 };

@adamdubiel
Copy link
Collaborator

I would like you to go into target-grunt directory in project root and run grunt, to see how much time will it take for vanilla grunt tasks.

@dbclkclk
Copy link
Author

this issue can be closed, had a trojan that replicated my target directory into a file size of 3 Gigs.

@dbclkclk dbclkclk reopened this Mar 29, 2015
@dbclkclk
Copy link
Author

Reopening this issue. I'm still getting the problem. Running the command in the target-grunt directory has the same issue. When I go into the directory I'm seeing this issue (as per screenshot) - note the directory path with multiple dist directory.

error

@dbclkclk
Copy link
Author

went as far as this for the directorty structure C:\Users\xxxx\TARGET~1\dist\dist\dist\dist\dist\dist\dist\NODE_M~1\bower\NODE_M~1\insight\NODE_M~1\inquirer\NODE_M~1\CLI-CO~1\NODE_M~1\memoizee\NODE_M~1\ES6-WE~1\NODE_M~1\ES6-IT~1\NODE_M~1\es6-symbol\test

@adamdubiel
Copy link
Collaborator

If you have the same issue when running vanilla grunt in target-grunt, it means there is something strange with your grunt build. Can you disable (remove if you like) mavenPrepare and mavenDist tasks and run it once again to rule them out?

@dbclkclk
Copy link
Author

@adamdubiel Will do in a moment. One other question, does maven-grunt task clean relies on the maven-clean-plugin? In my case, I don't have it and I believe this plugin uses it to clean the target-grunt directory each time it's executed.

@adamdubiel
Copy link
Collaborator

target-grunt does not get cleaned unless you specifically call mvn grunt:clean.

@dbclkclk
Copy link
Author

@adamdubiel i disabled those tasks and removed the 'target-grunt' long with the 'target' directory and things seems to sped up. Not sure what I'm doing wrong.

From the get go, I run mvn install to get all dependency (maven and grunt dependencies) and then run Tomcat. I figure by running mvn install, the grunt tasks are somehow injected into the normal maven lifecycle.

Subsequently, when I make modification to my js files, I run mvn test, to redeploy the grunt dependencies into the target-grunt directory (which after build, gets copied to the target directory).

Also, again why does the plugin creates so many levels deep in the target-grunt and target directories: `C:\Users\xxxx\TARGET1\dist\dist\dist\dist\dist\dist\dist\NODE_M1\bower\NODE_M1\insight\NODE_M1\inquirer\NODE_M1\CLI-CO1\NODE_M1\memoizee\NODE_M1\ES6-WE1\NODE_M1\ES6-IT1\NODE_M1\es6-symbol\test'.

See the many dist and NODE_M~1 directories? If i'm missing something here, let me know.

Thanks

@dbclkclk
Copy link
Author

I"m not sure why is it that each time mvn grunt:grunt -Dtarget=watch fires (due to changes) or just the normal maven install, this plugin creates additional dist directories in the target-grunt directory (which gets copied to target directory). I had so many dist created, i couldn't delete them because, Windows was complaining I had too many (path too long). I had to mount a new drive to lower levels of the dist directories and remove them (incrementally).

Example, after I manually deleted the target and target-watch directories, run maven install (which would recreate the target and target-grunt directories) and then run tomcat. I then ran the command mvn grunt:grunt -Dtarget=watch and made changes to my file, this would cause the build to run a second time. When I check the console, I'm seeing a second level dist directory being created:

Reading C:\Users\xxxxxxgit\xxxxxx\xxxxxxx-web\xxxxxxx_web\target-grunt\dist\node_modules\bower\node_modules\inquirer\node_modules\cli-color\node_modules\es5-ext\n ode_modules\es6-symbol\polyfill.js...OK

Writing C:\Users\xxxxxxx\git\xxxxx\xxxxxxx-web\xxxxxxx_web\target-grunt\dist\dist\node_modules\bower\node_modules\inquirer\node_modules\cli-color\node_modules\es5- ext\node_modules\es6-symbol\polyfill.js

See the writing statement above and 2 dist directories created.

@adamdubiel
Copy link
Collaborator

There should be just one dist, not many - this leads to some error in Grunt configuration, but since your config is quite big, i don't see any immediate suspect. How about trimming your Gruntfile piece by piece until you get to the moment where it does not create those dists anymore? You can even start with mavenPrepare and mavenDist.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants