You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Pankaj Tandon <pa...@gmail.com> on 2009/01/29 14:59:02 UTC

Plugin calling shell script

Hello,
I have written a plugin that uses Wagon to remotely execute a command on a
remote machine. But now I find that instead of executing a simple unix
command, I need to execute a whole shell script. 
So I created a shell script and placed it in src/main/resources, so that it
correctly gets bundled in the root of my plugin jar.
However, the problem is that how do users of my plugin get at that shell
script.
My users have configured my plugin in their poms. The corporate maven repo
holds my plugin jar also. But when they run the mvn command, and my plugin
is dutifully downloaded from the corporate maven repo to their local repo. 
>From there, however, things don't work. The plugin cannot find the shell
script because altho the shell script is in the plugin jar (in their local
repo), it is not in the classpath of the maven execution. 

So how do I invoke a shell script that is bundled as a part of the plugin?

I even tried 
URL url = MultiplexerMojo.class.getResource("sql.bash");

but url evaluates to null because sql.bash is not found (because the plugin
jar is not in the cp).

Is there anyway I can use plexus to inject the sql.bash into my plugin? Or
somehow add to the classpath that is examined by maven ?

Any help will be much appreciated!

Thanks,
Pankaj


 
-- 
View this message in context: http://www.nabble.com/Plugin-calling-shell-script-tp21727380p21727380.html
Sent from the Maven - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Plugin calling shell script

Posted by Pankaj Tandon <pa...@gmail.com>.
Thanks Gabriele,
That is a really good solution.. altho a bit of an overkill in my situation
but does separate plugin and the scripts, as they should be. 
I'll try it and post to the group.

Pankaj


Gabriele Columbro-2 wrote:
> 
> What about packaging another jar which holds your script (s)  (e.g.
> mojo-scritps.jar) and add this in the specific plugin dependencies
> section,
> something like:
> 
> <plugin>
> <dependencies>
>    <dependency>
>      <artifactId>mojo-scripts.jar</artifactId>
>   </dependency>
> </dependencies>
> </plugin>
> 
> 
> Would this solve your problem? (not sure if I completely understood the
> problem)
> 
> HTH,
> Gab
> 
> 
> 2009/1/29 Pankaj Tandon <pa...@gmail.com>
> 
>>
>> Hello,
>> I have written a plugin that uses Wagon to remotely execute a command on
>> a
>> remote machine. But now I find that instead of executing a simple unix
>> command, I need to execute a whole shell script.
>> So I created a shell script and placed it in src/main/resources, so that
>> it
>> correctly gets bundled in the root of my plugin jar.
>> However, the problem is that how do users of my plugin get at that shell
>> script.
>> My users have configured my plugin in their poms. The corporate maven
>> repo
>> holds my plugin jar also. But when they run the mvn command, and my
>> plugin
>> is dutifully downloaded from the corporate maven repo to their local
>> repo.
>> From there, however, things don't work. The plugin cannot find the shell
>> script because altho the shell script is in the plugin jar (in their
>> local
>> repo), it is not in the classpath of the maven execution.
>>
>> So how do I invoke a shell script that is bundled as a part of the
>> plugin?
>>
>> I even tried
>> URL url = MultiplexerMojo.class.getResource("sql.bash");
>>
>> but url evaluates to null because sql.bash is not found (because the
>> plugin
>> jar is not in the cp).
>>
>> Is there anyway I can use plexus to inject the sql.bash into my plugin?
>> Or
>> somehow add to the classpath that is examined by maven ?
>>
>> Any help will be much appreciated!
>>
>> Thanks,
>> Pankaj
>>
>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Plugin-calling-shell-script-tp21727380p21727380.html
>> Sent from the Maven - Users mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>>
>>
> 
> 
> -- 
> Gabriele Columbro
> Alfresco ECM Product Strategy Consultant
> +31 627 565 103
> Sourcesense - Making sense of open Source (http://www.sourcesense.com)
> 
> 

-- 
View this message in context: http://www.nabble.com/Plugin-calling-shell-script-tp21727380p21750756.html
Sent from the Maven - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Plugin calling shell script

Posted by Gabriele Columbro <g....@sourcesense.com>.
What about packaging another jar which holds your script (s)  (e.g.
mojo-scritps.jar) and add this in the specific plugin dependencies section,
something like:

<plugin>
<dependencies>
   <dependency>
     <artifactId>mojo-scripts.jar</artifactId>
  </dependency>
</dependencies>
</plugin>


Would this solve your problem? (not sure if I completely understood the
problem)

HTH,
Gab


2009/1/29 Pankaj Tandon <pa...@gmail.com>

>
> Hello,
> I have written a plugin that uses Wagon to remotely execute a command on a
> remote machine. But now I find that instead of executing a simple unix
> command, I need to execute a whole shell script.
> So I created a shell script and placed it in src/main/resources, so that it
> correctly gets bundled in the root of my plugin jar.
> However, the problem is that how do users of my plugin get at that shell
> script.
> My users have configured my plugin in their poms. The corporate maven repo
> holds my plugin jar also. But when they run the mvn command, and my plugin
> is dutifully downloaded from the corporate maven repo to their local repo.
> From there, however, things don't work. The plugin cannot find the shell
> script because altho the shell script is in the plugin jar (in their local
> repo), it is not in the classpath of the maven execution.
>
> So how do I invoke a shell script that is bundled as a part of the plugin?
>
> I even tried
> URL url = MultiplexerMojo.class.getResource("sql.bash");
>
> but url evaluates to null because sql.bash is not found (because the plugin
> jar is not in the cp).
>
> Is there anyway I can use plexus to inject the sql.bash into my plugin? Or
> somehow add to the classpath that is examined by maven ?
>
> Any help will be much appreciated!
>
> Thanks,
> Pankaj
>
>
>
> --
> View this message in context:
> http://www.nabble.com/Plugin-calling-shell-script-tp21727380p21727380.html
> Sent from the Maven - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>


-- 
Gabriele Columbro
Alfresco ECM Product Strategy Consultant
+31 627 565 103
Sourcesense - Making sense of open Source (http://www.sourcesense.com)