Thanks, that will solve only one part of of the problem. The other part is
how to tell the Assembly Mojo where to read resources from. Since I want to
generate two archives with different properties, I am generating two separate
directories using the Maven Resources plugin (in combination with filtering).
So I will have two directories that I want the Assembly Mojo to use instead of
the default. The Assembly Mojo has:
// Include project classes content
if (includeBuildOutputDirectory)
IoUtils.copyDirectory(new
File(project.getBuild().getOutputDirectory()), workDirectory);
So it is hard coded to copy the target/classes directory; there is no way to
tell it to look somewhere else.
By comparison, the ArchiveMojo does have a property you can use to override its
source dir:
/**
* The location of the server repository.
*/
@Parameter(defaultValue="${project.build.directory}/assembly")
private File targetServerDirectory;
which is great, because I can have multiple versions of the assembly directory
for different executions of the plugin.
To support multiple executions, I think the Assembly Mojo needs to be able to
read from different paths. Would this be possible?
Best regards,
Alex soto
> On Apr 21, 2016, at 1:30 PM, Jean-Baptiste Onofré <[email protected]> wrote:
>
> Yes it's something that we can extend.
>
>
> -------- Original message --------
> From: Alex Soto <[email protected]>
> Date: 21/04/2016 18:23 (GMT+00:00)
> To: [email protected]
> Subject: Re: karaf-maven-plugin multiple outputs with classifiers
>
> I found this fragment:
>
>
> if (targetFile != null &&
> project.getPackaging().equals("karaf-assembly")) {
> serverName = targetFile.getName();
> } else {
> serverName = artifact.getArtifactId() + "-" +
> artifact.getVersion();
> }
>
> Means that target file is only honored when the pom packaging is
> ‘karat-assembly’ which greatly limits the plugin.
> Is there any strong reason for this? Why not honor the targetFile property
> in all cases?
>
>
> Best regards,
> Alex soto
>
>
>
>> On Apr 21, 2016, at 12:56 PM, Morgan Hautman <[email protected]
>> <mailto:[email protected]>> wrote:
>>
>> Hi Alex,
>>
>> Take a look at the code here
>> https://github.com/apache/karaf/tree/master/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling
>>
>> <https://github.com/apache/karaf/tree/master/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling>
>>
>> There is an "AssemblyMojo" & a ArchiveMojo (the 2 ones you use).
>>
>> There are all the parameters defined for a specific goal, with sometimes
>> some comments on the parameter.
>>
>> I hope this help you clarify it a bit.
>>
>> Regards,
>> Morgan
>>
>> PS: JB is away (travel) so he may not immediately respond if you need his
>> knowledge.
>>
>> On 2016-04-21 17:10, Alex Soto wrote:
>>> Not having any luck here!!
>>>
>>> Changed pom packaging to ‘pom’ and configured both goals ‘assembly’ and
>>> ‘archive’ as separate executions:
>>>
>>> <plugin>
>>> <groupId>org.apache.karaf.tooling</groupId>
>>> <artifactId>karaf-maven-plugin</artifactId>
>>> <executions>
>>> <execution>
>>> <id>gen-assembly-la1</id>
>>> <phase>prepare-package</phase>
>>> <goals>
>>> <goal>assembly</goal>
>>> </goals>
>>> <configuration>
>>> <classifier>la1</classifier>
>>>
>>> <resourcesDir>${project.build.directory}/la1/resources</resourcesDir>
>>>
>>> <targetServerDirectory>${project.build.directory}/la1/assembly</targetServerDirectory>
>>>
>>>
>>> Both the <resourcesDir> and <targetServerDirectory> are ignored.
>>>
>>> Then on the archive goal:
>>>
>>> <execution>
>>> <id>package-la1</id>
>>> <phase>package</phase>
>>> <goals>
>>> <goal>archive</goal>
>>> </goals>
>>> <configuration>
>>>
>>> <classifier>la1</classifier>
>>>
>>> <archiveTarGz>true</archiveTarGz>
>>>
>>> <archiveZip>false</archiveZip>
>>>
>>> <targetFile>${project.artifactId}-${project.version}-la1</targetFile>
>>> </configuration>
>>> </execution>
>>>
>>> It also ignores the <targetFile> configuration. This should’t be that
>>> hard, what’s going on? Any help?
>>>
>>> Best regards,
>>> Alex soto
>>>
>>>
>>>> On Apr 20, 2016, at 4:14 PM, Alex Soto <[email protected]
>>>> <mailto:[email protected]>> wrote:
>>>>
>>>> Is there a good example? The one in the Karaf documentation page does not
>>>> address this scenario, which is not uncommon; usually you will need
>>>> different settings for each environment (DEV, TEST, UAT, PROD, etc.,) so
>>>> cloning the project is not a practical approach. I tried with profiles
>>>> but that too is not very practical, since you have build the same project
>>>> multiple times, and the resulting archives are not deployed correctly to
>>>> the Maven repository.
>>>>
>>>>
>>>>> On Apr 20, 2016, at 11:03 AM, Alex Soto <[email protected]
>>>>> <mailto:[email protected]>> wrote:
>>>>>
>>>>> Thank you JB,
>>>>>
>>>>> Which goal should I use?
>>>>>
>>>>>
>>>>> Best regards,
>>>>> Alex Soto
>>>>>
>>>>>
>>>>>> On Apr 20, 2016, at 10:18 AM, Jean-Baptiste Onofré <[email protected]
>>>>>> <mailto:[email protected]>> wrote:
>>>>>>
>>>>>> Hi Alex
>>>>>>
>>>>>> Using execution with the goal should do the trick (instead of just
>>>>>> plugin definition).
>>>>>>
>>>>>> Regards
>>>>>> JB
>>>>>>
>>>>>>
>>>>>> -------- Original message --------
>>>>>> From: Alex Soto <[email protected] <mailto:[email protected]>>
>>>>>> Date: 20/04/2016 15:19 (GMT+01:00)
>>>>>> To: [email protected] <mailto:[email protected]>
>>>>>> Subject: karaf-maven-plugin multiple outputs with classifiers
>>>>>>
>>>>>> Hello,
>>>>>>
>>>>>> I am trying (unsuccessfully) to us the 'karaf-maven-plugin’ to generate
>>>>>> multiple archives from the same pom, using classifiers and executions.
>>>>>>
>>>>>> I have something like this:
>>>>>>
>>>>>>
>>>>>> <plugin>
>>>>>> <groupId>org.apache.karaf.tooling</groupId>
>>>>>> <artifactId>karaf-maven-plugin</artifactId>
>>>>>> <configuration>
>>>>>> <bootFeatures>
>>>>>> <feature>wrap</feature>
>>>>>> <feature>aries-blueprint</feature>
>>>>>> <feature>shell</feature>
>>>>>> <feature>shell-compat</feature>
>>>>>> <feature>feature</feature>
>>>>>> <feature>jaas</feature>
>>>>>> <feature>ssh</feature>
>>>>>> <feature>management</feature>
>>>>>> <feature>bundle</feature>
>>>>>> <feature>config</feature>
>>>>>> <feature>deployer</feature>
>>>>>> <feature>diagnostic</feature>
>>>>>> <feature>feature</feature>
>>>>>> <feature>instance</feature>
>>>>>> <feature>kar</feature>
>>>>>> <feature>log</feature>
>>>>>> <feature>package</feature>
>>>>>> <feature>service</feature>
>>>>>> <feature>system</feature>
>>>>>> </bootFeatures>
>>>>>> </configuration>
>>>>>> <executions>
>>>>>> <execution>
>>>>>> <id>la1</id>
>>>>>> <configuration>
>>>>>> <classifier>la1</classifier>
>>>>>> <resourcesDir>${project.build.outputDirectory}/la1</resourcesDir>
>>>>>> </configuration>
>>>>>> </execution>
>>>>>> <execution>
>>>>>> <id>la2</id>
>>>>>> <configuration>
>>>>>> <classifier>la2</classifier>
>>>>>> <resourcesDir>${project.build.outputDirectory}/la2</resourcesDir>
>>>>>> </configuration>
>>>>>> </execution>
>>>>>> </executions>
>>>>>> </plugin>
>>>>>>
>>>>>>
>>>>>> The difference between the two archives is in the resources, so I am
>>>>>> specifying different ‘resourcesDir’ paths for each. The list of boot
>>>>>> features will be the same for both executions, so I put it in the
>>>>>> general configuration section of the plugin.
>>>>>>
>>>>>> When built, I am only getting a single archive output.
>>>>>> Is it possible to do this with the 'karaf-maven-plugin’ plugin?
>>>>>>
>>>>>> Best regards,
>>>>>> Alex soto
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>
>