You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Tushar Kapila <tg...@gmail.com> on 2017/03/07 10:59:04 UTC

Possible to use maven API to get another projects binaries ?

hello

I would like to get  output binaries -how many/ name and output paths,
of an arbitrary maven project. It could have multiple ways / profiles
of being built (for example client jar, service app and front end war
file, the way to build these will be with me, provided in a build.json
file with in my own format, by the project maintainer.

Is there a way, to not build the project, nor make a plugin, but some
how query maven, giving it the profile and the pom.xml as input, and
getting the list of project artifacts of the package step? In some it
could be the default jar, in others a war file but not with the
artifact's name (over ridden output file name).

A project can have many profiles, if it has any, I will have
information on one or more profile names I'm interested in.

Even if a plugin changes the exact name or path of a output binary,
will the maven API still know the new path? Let's assume its a well
behaved standard plugin like the jar plugin?

Are there any samples for this?
-- 
Regards
Tushar Kapila

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


Re: Possible to use maven API to get another projects binaries ?

Posted by Thomas Broyer <t....@gmail.com>.
Le mar. 7 mars 2017 12:49, Tushar Kapila <tg...@gmail.com> a écrit :

> So is my best bet to make a OS Process, collect the output and parse
> the text to get files created like the following maven run snippet:
>
>
>
> Tests run: 3, Failures: 0, Errors: 0, Skipped: 0
>
> [INFO]
> [INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ CmdLineCalc ---
> [INFO] Building jar:
>
> /Users/dev1/u/w/github/tgkprog/mavenSampleCalcCmdLineProject/CmdLineCalc/target/CmdLineCalc-1.jar
> [INFO] META-INF/maven/s2n.sample.calc.cmdLine/CmdLineCalc/pom.xml
> already added, skipping
> [INFO] META-INF/maven/s2n.sample.calc.cmdLine/CmdLineCalc/pom.properties
> already added, skipping
> [INFO]
> ------------------------------------------------------------------------
> [INFO] BUILD SUCCESS
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Total time: 1.659 s
> [INFO] Finished at: 2017-03-07T15:46:32+05:30
> [INFO] Final Memory: 16M/212M
> [INFO]
> ------------------------------------------------------------------------
>
> ---
>
> if I see a BUILD SUCCESS, then work back a few lines to find jars, wars,
> etc?
>

No, you should use Maven's API to get that information accurately. What I
meant is that you can't know it without running the build.

Re: Possible to use maven API to get another projects binaries ?

Posted by Tushar Kapila <tg...@gmail.com>.
So is my best bet to make a OS Process, collect the output and parse
the text to get files created like the following maven run snippet:



Tests run: 3, Failures: 0, Errors: 0, Skipped: 0

[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ CmdLineCalc ---
[INFO] Building jar:
/Users/dev1/u/w/github/tgkprog/mavenSampleCalcCmdLineProject/CmdLineCalc/target/CmdLineCalc-1.jar
[INFO] META-INF/maven/s2n.sample.calc.cmdLine/CmdLineCalc/pom.xml
already added, skipping
[INFO] META-INF/maven/s2n.sample.calc.cmdLine/CmdLineCalc/pom.properties
already added, skipping
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.659 s
[INFO] Finished at: 2017-03-07T15:46:32+05:30
[INFO] Final Memory: 16M/212M
[INFO] ------------------------------------------------------------------------

---

if I see a BUILD SUCCESS, then work back a few lines to find jars, wars, etc?

On Tue, Mar 7, 2017 at 4:59 PM, Thomas Broyer <t....@gmail.com> wrote:
> On Tue, Mar 7, 2017 at 11:59 AM Tushar Kapila <tg...@gmail.com> wrote:
>
>> hello
>>
>> I would like to get  output binaries -how many/ name and output paths,
>> of an arbitrary maven project. It could have multiple ways / profiles
>> of being built (for example client jar, service app and front end war
>> file, the way to build these will be with me, provided in a build.json
>> file with in my own format, by the project maintainer.
>>
>> Is there a way, to not build the project, nor make a plugin, but some
>> how query maven, giving it the profile and the pom.xml as input, and
>> getting the list of project artifacts of the package step? In some it
>> could be the default jar, in others a war file but not with the
>> artifact's name (over ridden output file name).
>>
>> A project can have many profiles, if it has any, I will have
>> information on one or more profile names I'm interested in.
>>
>> Even if a plugin changes the exact name or path of a output binary,
>> will the maven API still know the new path? Let's assume its a well
>> behaved standard plugin like the jar plugin?
>>
>
> Due to the way Maven is designed, it has no knowledge of the outputs (nor
> even the inputs!) of a plugin, including whether and which artifact(s) will
> be attached, without actually running the mojo.
> You could possibly infer it, but it would require precise knowledge of all
> the plugins used in the build and how they use their configurations
> (including parsing plugin-specific files such as assembly descriptors for
> the maven-assembly-plugin).



-- 
Regards
Tushar Kapila

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


Re: Possible to use maven API to get another projects binaries ?

Posted by "Christopher M. Logan" <ch...@worlwin.com>.
<div name="BB10" id="BB10_FLOT" contenteditable="false" style="display:none"></div>                                                                                      <div name="BB10" id="BB10_response_div" dir="auto" contenteditable="true"                                                                                             style="width:100%;background:&quot;#ffffff&quot;; font-size: initial;font-family:&quot;Calibri&quot;,&quot;Slate Pro&quot;,sans-serif,&quot;sans-serif&quot;;color:#1f497d;"><br style="display:initial"></div>                                                                                                                                     <div name="BB10" id="response_div_spacer" dir="auto" contenteditable="true"                                                                                           style="width:100%;background:&quot;#ffffff&quot;; font-size: initial;font-family:&quot;Calibri&quot;,&quot;Slate Pro&quot;,sans-serif,&quot;sans-serif&quot;;color:#1f497d;"><br style="display:initial"></div>                                                                                                                                     <div name="BB10" id="blackberry-text-learn-end" contenteditable="false" style="display:none"></div>                                                              <div id="_signaturePlaceholder" name="BB10" dir="auto"  contenteditable="true"                                                                                      style="font-size: initial;font-family:&quot;Calibri&quot;,&quot;Slate Pro&quot;,sans-serif,&quot;sans-serif&quot;;color:#1f497d;"></div>                                       <div name="BB10" id="BB10_LLOT" contenteditable="false" style="display:none"></div><div id="_bb10TempSeparator" contenteditable="false"><table width="100%" style="background-color:white; border-spacing:0px;">                                          <tr><td></td><td id="_separatorInternal" rowspan=2 style="text-align:center">                                                                                            <span id="_bb10TempSeparatorText" style="background-color:white; color:#0073BC;font-size:smaller;font-family:&quot;Slate Pro&quot;">&nbsp; Original Message &nbsp;</span>      </td></tr>                                                                                                                                                               <tr> <td colspan=2><div style="border:none;border-top:solid #0073BC 1.0pt;"></div>                                                                                     </td></tr></table></div>                                                                                                                                           <table id='_pHCWrapper' width="100%" style="background-color:white;border-spacing:0px;"> <tr><td id="_persistentHeaderContainer" colspan=2>                           <div id="_persistentHeader" style="font-size: smaller;font-family:&quot;Tahoma&quot;,&quot;BB Alpha Sans&quot;,&quot;Slate Pro&quot;,sans-serif,&quot;sans-serif&quot;;">  <div id=From ><b>From: </b>Thomas Broyer</div><div id=Sent ><b>Sent: </b>Tuesday, March 7, 2017 6:37 AM</div><div id=To ><b>To: </b>Maven Users List</div><div id=ReplyTo ><b>Reply To: </b>Maven Users List</div><div id=Subject ><b>Subject: </b>Re: Possible to use maven API to get another projects binaries ?</div></div></td></tr></table><div id="_persistentHeaderEnd" style="border:none;border-top:solid #babcd1 1pt;"></div><br><div name="BB10" dir="auto" id="_originalContent">On Tue, Mar 7, 2017 at 11:59 AM Tushar Kapila &lt;tgkprog@gmail.com&gt; wrote:<br/><br/>&gt; hello<br/>&gt;<br/>&gt; I would like to get  output binaries -how many/ name and output paths,<br/>&gt; of an arbitrary maven project. It could have multiple ways / profiles<br/>&gt; of being built (for example client jar, service app and front end war<br/>&gt; file, the way to build these will be with me, provided in a build.json<br/>&gt; file with in my own format, by the project maintainer.<br/>&gt;<br/>&gt; Is there a way, to not build the project, nor make a plugin, but some<br/>&gt; how query maven, giving it the profile and the pom.xml as input, and<br/>&gt; getting the list of project artifacts of the package step? In some it<br/>&gt; could be the default jar, in others a war file but not with the<br/>&gt; artifact&apos;s name (over ridden output file name).<br/>&gt;<br/>&gt; A project can have many profiles, if it has any, I will have<br/>&gt; information on one or more profile names I&apos;m interested in.<br/>&gt;<br/>&gt; Even if a plugin changes the exact name or path of a output binary,<br/>&gt; will the maven API still know the new path? Let&apos;s assume its a well<br/>&gt; behaved standard plugin like the jar plugin?<br/>&gt;<br/><br/>Due to the way Maven is designed, it has no knowledge of the outputs (nor<br/>even the inputs!) of a plugin, including whether and which artifact(s) will<br/>be attached, without actually running the mojo.<br/>You could possibly infer it, but it would require precise knowledge of all<br/>the plugins used in the build and how they use their configurations<br/>(including parsing plugin-specific files such as assembly descriptors for<br/>the maven-assembly-plugin).<br/>

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


Re: Possible to use maven API to get another projects binaries ?

Posted by Thomas Broyer <t....@gmail.com>.
On Tue, Mar 7, 2017 at 11:59 AM Tushar Kapila <tg...@gmail.com> wrote:

> hello
>
> I would like to get  output binaries -how many/ name and output paths,
> of an arbitrary maven project. It could have multiple ways / profiles
> of being built (for example client jar, service app and front end war
> file, the way to build these will be with me, provided in a build.json
> file with in my own format, by the project maintainer.
>
> Is there a way, to not build the project, nor make a plugin, but some
> how query maven, giving it the profile and the pom.xml as input, and
> getting the list of project artifacts of the package step? In some it
> could be the default jar, in others a war file but not with the
> artifact's name (over ridden output file name).
>
> A project can have many profiles, if it has any, I will have
> information on one or more profile names I'm interested in.
>
> Even if a plugin changes the exact name or path of a output binary,
> will the maven API still know the new path? Let's assume its a well
> behaved standard plugin like the jar plugin?
>

Due to the way Maven is designed, it has no knowledge of the outputs (nor
even the inputs!) of a plugin, including whether and which artifact(s) will
be attached, without actually running the mojo.
You could possibly infer it, but it would require precise knowledge of all
the plugins used in the build and how they use their configurations
(including parsing plugin-specific files such as assembly descriptors for
the maven-assembly-plugin).