0

When running a command-line script, is it possible to get the name of the current Maven profile name we are running?

elee
  • 43
  • 1
  • 5
  • can you add more information here ? your title says u need to pass a profile to a batch file and your question says getting profile info from running script ? please add more info your looking for ? to quickly answer to your title , yes we can pass maven profile name to batch . – prudviraj Jun 08 '16 at 08:37
  • I am running a Maven profile. For example say the profile name as WORLD. I have used maven-exec-plugin for running the batch file and i want to pass the profile name(WORLD) to that batch file. You said that it is possible. Can you explain how it will be? I have tried set arg1=%0 echo %arg1%. But it is not printing the profile name. It is printing batch file location. if possible please tell me with an example. I am completely new to this topic. – elee Jun 08 '16 at 08:44
  • Just an FYI %0 will give u filename in bat this is expected , this is a reserved token , please use %1 instead to get the first input value and so on. try this set arg1=%1 echo %arg1% – prudviraj Jun 08 '16 at 08:57
  • I have tried upto %9 from %1. No use. It is not printing the name of the profile – elee Jun 08 '16 at 09:13

1 Answers1

0

when you are executing a bat file using maven-exec plugin , you can define in the bat file a call function to call the origin bat file along with arguments , or you can add arguments as defined below.

<arguments>
 <argument>8.8.8.8</argument>
 </arguments>

please refer to below answer in stackoverflow for more context :

Link1

Link2

Community
  • 1
  • 1
prudviraj
  • 3,634
  • 2
  • 16
  • 22
  • Thanks prudviraj.... But it doesn't help me....I need only the profile name WORLD in my batch file....if I change my profile name to TEST for time being it should automatically print the TEST in the batch file...That's my question.... – elee Jun 08 '16 at 09:08