micha149 / gulp-maven-deploy

Gulp wrapper for the maven-deploy plugin
MIT License
12 stars 11 forks source link

Use the filename as ArtifactId #5

Closed jmorille closed 8 years ago

jmorille commented 9 years ago

In case of multiple file for file to deploy, I could be interesting to have the possibility to generate the options to pass to maven-deploy (like artifact ID) My use case is android file for multiple device

 android-armv7-debug.apk
 android-armv7-debug-unaligned.apk
 android-x86-debug.apk
 android-x86-debug-unaligned.apk

The solution Add the possibility to add a callback function with the current file that return the json option, instead of the json object. with a Api like this

gulp.task('deploy', function(){
    gulp.src('.')
    .pipe(maven.deploy( function(file) {
      var fileName = file.relative;
      return {
        'config': {
            'groupId': 'com.mygroup',
            'artifactId': fileName
            'type': 'apk',
            'repositories': [
                {
                    'id': 'some-repo-id',
                    'url': 'http://some-repo/url'
                }
            ]
        }
     }))
});
gregersrygg commented 9 years ago

I don't have much experience with Gulp, but at least this makes it possible to do something with the files Gulp passes along :) What do you think @sveisvei ?

leftieFriele commented 9 years ago

Can't you achieve this by just using gulp? You have the file names in a list and then call maven deploy for each file? That is what you usually do in Gulp isn't it?

jmorille commented 9 years ago

I am not so famillar with gulp. But I think that you can't do that without refactoring your code to move the check validate inside the gulp callback (file, cb) and test if the option is an json object or a function. In the last case your code have to call the function with the current file.

leftieFriele commented 9 years ago

gulp.src docs says it returns a stream of Vinyl-files, wouldn't that make it possible to do something like:

gulp.src('*.')
        .pipe(
            map(
                function(file) {
                    console.log(file.path);
                    maven.deploy({
                          ....
                    });
                }
            )
        )
jmorille commented 9 years ago

Yes is possible, like a workaround. But I hopping a more integrated api with an something like that A pre parsed file, should be an better parameter the the file It self that permit to simple use of your plugins in multiple file.

gulp.task('deploy', function () {
  var maven = require('gulp-maven-deploy');
  gulp.src('dist/cca_android/**/*.apk', {base: '.'}) 
    .pipe(maven.deploy(function (fileParsed, cb) {
        return {
          'config': {
            'groupId':  'com.mygroup',
            'artifactId': fileParsed.name,
            'type': fileParsed.extname,
            'repositories': [  {  'id': 'some-repo-id',  'url': 'http://some-repo/url' }  ]
          }
        };
      }
    ))
}); 

I will do a pullrequest.

leftieFriele commented 9 years ago

wouldn't this change require a breaking change in the maven-deploy module as well, as it currently doesn't support taking in files as an argument?

jmorille commented 9 years ago

I am not understand what could be the problem. Did you say that maven-deploy was not thread safe ? My pull request permit to keep the backwards api compatibility with the eval of function and keep the json object argument And call the maven-deploy api like you advice as workaround.

leftieFriele commented 9 years ago

Sorry about the confusion, I finally got my machine setup to run your sample. Please check the PR. @gregersrygg perhaps you allow me to merge PRs again? :)

leftieFriele commented 9 years ago

I got the control of this project back @jmorille, sorry about the incredibly long delay... I'll merge the PR, if you want to become a contributor let me know. I'm not working in a Java environment these days so I won't be making a lot of new additions to this module.

micha149 commented 8 years ago

I am thinking about this in a new major release which should bring a better gulp behavior. So, I would prefer to handle file names as artifact ids and file extensions as types by default. I think this would play nice with the idea to remove the packaging from this plugin…

Example:

gulp.src('src/*')
    .pipe(zip('my-artifact-name.war'))
    .pipe(deploy(deployOptions))

in your case you could omit the zip step and the plugin will deploy 4 artifacts with the names android-armv7-debug, android-armv7-debug-unaligned, android-x86-debug and android-x86-debug-unaligned. All from type apk.

Any vetos?

micha149 commented 8 years ago

Yesterday I released version 1.0.0-beta.5 wich brings the announced behavior. Can someone check if this works as expected by you? If it does, I would like to release version 1.0.0 in a week, if no bugs occur.