Skip to content
This repository has been archived by the owner on Jan 7, 2019. It is now read-only.

mavenDist copies build dir, not compile dir #4

Closed
keithkml opened this issue Dec 16, 2014 · 8 comments
Closed

mavenDist copies build dir, not compile dir #4

keithkml opened this issue Dec 16, 2014 · 8 comments

Comments

@keithkml
Copy link

I'm new to Grunt, but I was expecting mavenDist to copy my final minified files (aka the contents of target-grunt/bin), not my intermediate files (aka the contents of target-grunt/build).

screen shot 2014-12-16 at 11 13 54 am

Relevant lines from Gruntfile.js:

  grunt.registerTask( 'default', [ 'mavenPrepare', 'build', 'compile', 'mavenDist' ] );

// ...

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

    mavenDist: {
      options: {
        warName: 'server-1.0-SNAPSHOT',
        deliverables: ['**', '!non-deliverable.js'],
        gruntDistDir: 'dist'
      },
      dist: {}
    },

    gruntMavenProperties: grunt.file.readJSON('grunt-maven.json'),

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

And from pom.xml:

            <plugin>
                <groupId>pl.allegro</groupId>
                <artifactId>grunt-maven-plugin</artifactId>
                <version>1.4.1</version>
                <configuration>
                    <gruntOptions>
                        <gruntOption>--force</gruntOption>
                    </gruntOptions>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>create-resources</goal>
                            <goal>npm</goal>
                            <goal>bower</goal>
                            <goal>grunt</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
@adamdubiel
Copy link
Collaborator

It copies all deliverables from target-grunt/ that match patterns, by default it's **. If you need only files from bin/, then set: deliverables: ['bin/**'] .

@keithkml
Copy link
Author

OK, but then how would I move them out of bin/ and into static? I don't want my URL to be http://mydomain.com/static/bin :)

@adamdubiel
Copy link
Collaborator

Sure thing :) Just try it out, i'm not 100% sure, but i think it will be copied just as you want it to be, i.e. having bin/hello.min.js it will be copied to dist/hello.min.js and then it will go over to WAR to war/static/hello.min.js. I still need to make this static part optional in war path, but theres another issue for it.

@keithkml
Copy link
Author

Nope doesn't work :)

screen shot 2014-12-16 at 12 05 32 pm

@adamdubiel
Copy link
Collaborator

Okay, fortunately deliverables accepts simple Grunt patterns, and so probably can be configured to drop the bin/ prefix: http://gruntjs.com/configuring-tasks#files .

@keithkml
Copy link
Author

Sorry I don't understand, I read through that whole thing and don't see anything about dropping prefixes. Do you have an example?

@adamdubiel
Copy link
Collaborator

Okay, so i looked it up and unfortunately grunt-maven-plugin does not handle it the way i thought i remember. But there is a solution, just change gruntDistDir to bin and set deliverables to empty array. This way it will just copy contents of bin/ to your war.

@adamdubiel
Copy link
Collaborator

Closing under assumption my previous comment helped, if you have problems just reopen it :)

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