You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by jackett_dad <ja...@yahoo.com> on 2011/12/05 15:22:30 UTC

spring handlers

All,

I am having an issue that has been encountered before.  The issue concerns
the inclusion of a file called spring.handlers that exists in multiple
spring jars that are included with a project.  I'm building a release
version of a jar that includes its dependencies, such that there needs to
exist in the META-INF folder of the generated release jar a spring.handlers
containing a combination of all the spring.handlers encountered in all the
dependency jars collected and included.

The maven-shade-plugin has been offered as a solution for this situation,
but I am finding that the shade plugin is causing my compile to take too
long, and it creates many warning messages.  Putting aside that I need to
fine-tune my dependencies, and that the shade plugin is not all to blame for
the inefficiency of my build, I need another solution to get me
by--something that does not involve manual intervention on my part every
time I build.

What I would like to do is have maven ignore all spring.handlers entries,
and have the build substitute my own manually collected spring.handlers at
the end.  Is there an easy way to do this?  It looks like I could use the
DontIncludeResourceTransformer (if this also does not add too much time to
my build), and then include mine at the end, but I'm not sure if the
DontIncludeResourceTransformer would prevent me from doing so.

I'm open to writing my own plugins, but I haven't done this yet, and I'm
wondering how difficult this would be.

Thanks for any suggestions you can offer,

Scott

--
View this message in context: http://maven.40175.n5.nabble.com/spring-handlers-tp5048978p5048978.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: spring handlers

Posted by jackett_dad <ja...@yahoo.com>.
Ok, Benson, maybe that is the way to go then.  I'll have to update after
posting another question.  Thanks.

--
View this message in context: http://maven.40175.n5.nabble.com/spring-handlers-tp5048978p5049717.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: spring handlers

Posted by Benson Margulies <bi...@gmail.com>.
I think that I misunderstood. If you don't control the builds of the
jars that have the spring files in them, but merely aggregate them,
then I don't have any better suggestion than shade.

However, I wonder if we can help you make shade work better for you.

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


Re: spring handlers

Posted by jackett_dad <ja...@yahoo.com>.
Thanks for the reply.

Here's roughly my setup.  I have master project with multiple modules.  

prj - top level
  - gui
  - sv1
  - sv2

So prj is the parent projectg, gui, sv1 and sv2 are child modules of prj. 
The gui module has depencencies on sv1 and sv2, and all three modules have
spring dependencies, and so the resulting gui.war, sv1.jar and sv2.jar, will
each have spring.handlers in their META-INF folders (but the wrong
spring.handlers, since each will not have a composite of all
spring.handlers, only the last spring.handlers maven encounters while
building the assemblies).

Can anyone outline what specifically needs to be added to the build of each
of these modules to achieve the effect of excluding spring.handlers from the
assembly stage from all jars, and what would need to be added to provide my
spring.handlers to the META-INF folder of the final artifacts of each.

Thanks,

Scott

--
View this message in context: http://maven.40175.n5.nabble.com/spring-handlers-tp5048978p5049623.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: spring handlers

Posted by Benson Margulies <bi...@gmail.com>.
You would have configure the maven-jar-plugin to exclude it and then
make the combined one show up where you want it.

On Mon, Dec 5, 2011 at 9:22 AM, jackett_dad <ja...@yahoo.com> wrote:
> All,
>
> I am having an issue that has been encountered before.  The issue concerns
> the inclusion of a file called spring.handlers that exists in multiple
> spring jars that are included with a project.  I'm building a release
> version of a jar that includes its dependencies, such that there needs to
> exist in the META-INF folder of the generated release jar a spring.handlers
> containing a combination of all the spring.handlers encountered in all the
> dependency jars collected and included.
>
> The maven-shade-plugin has been offered as a solution for this situation,
> but I am finding that the shade plugin is causing my compile to take too
> long, and it creates many warning messages.  Putting aside that I need to
> fine-tune my dependencies, and that the shade plugin is not all to blame for
> the inefficiency of my build, I need another solution to get me
> by--something that does not involve manual intervention on my part every
> time I build.
>
> What I would like to do is have maven ignore all spring.handlers entries,
> and have the build substitute my own manually collected spring.handlers at
> the end.  Is there an easy way to do this?  It looks like I could use the
> DontIncludeResourceTransformer (if this also does not add too much time to
> my build), and then include mine at the end, but I'm not sure if the
> DontIncludeResourceTransformer would prevent me from doing so.
>
> I'm open to writing my own plugins, but I haven't done this yet, and I'm
> wondering how difficult this would be.
>
> Thanks for any suggestions you can offer,
>
> Scott
>
> --
> View this message in context: http://maven.40175.n5.nabble.com/spring-handlers-tp5048978p5048978.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
>

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


Re: spring handlers

Posted by jackett_dad <ja...@yahoo.com>.
Thanks for the ideas--I'll have to look into scripting for the future in
order to be robust enough to always have the right entries in
spring.handlers and spring.schemas.  The shade plugin actually wasn't being
invoked as I thought it was because I wasn't calling the package target. 
When I did, there was another issue with a manifest entry being missing,
leading me down another googling path.  

Here, though, is what I finally did.  I created a custom assembly and
referenced it from my module's POM.  I disabled unpacking of spring.* and
included my pre-made versions of the same.  It gets me by for now.

Here is the source of the assembly, called assembly.xml in the same folder
as the pom:

<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2
http://maven.apache.org/xsd/assembly-1.1.2.xsd">
    <id>jar-with-dependencies-exclude-spring-handlers</id>
    <formats>
        <format>jar</format>
    </formats>
    <includeBaseDirectory>false</includeBaseDirectory>
    <dependencySets>
        <dependencySet>
            <outputDirectory>/</outputDirectory>
            <useProjectArtifact>true</useProjectArtifact>
            <unpack>true</unpack>
            <scope>runtime</scope>
            <unpackOptions>
                <excludes>
                    <exclude>META-INF/spring.handlers</exclude>
                    <exclude>META-INF/spring.schemas</exclude>
                </excludes>
            </unpackOptions>
        </dependencySet>
    </dependencySets>
    <files>
        <file>
            <source>src/main/resources/META-INF/spring.handlers</source>
            <outputDirectory>META-INF</outputDirectory>
        </file>
        <file>
            <source>src/main/resources/META-INF/spring.schemas</source>
            <outputDirectory>META-INF</outputDirectory>
        </file>
    </files>
</assembly>

>From my POM, here is how I invoke it:

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>${maven.assembly.plugin.version}</version>
                <configuration>
                    <descriptors>
                        <descriptor>assembly.xml</descriptor>
                    </descriptors>
                </configuration>
            </plugin>
        </plugins>
    </build>

The maven assembly plugin version is defined in the parent project.  

--
View this message in context: http://maven.40175.n5.nabble.com/spring-handlers-tp5048978p5052522.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: spring handlers

Posted by jackett_dad <ja...@yahoo.com>.
Dirk,

I've never done any groovy scripting, but it looks like it is time to learn. 
I'm going to adapt what you have provided here.  Thanks.

Scott

--
View this message in context: http://maven.40175.n5.nabble.com/spring-handlers-tp5048978p5052063.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: spring handlers

Posted by Dirk Olmes <di...@xanthippe.ping.de>.
On 12/05/2011 03:22 PM, jackett_dad wrote:
> I am having an issue that has been encountered before.  The issue concerns
> the inclusion of a file called spring.handlers that exists in multiple
> spring jars that are included with a project.  I'm building a release
> version of a jar that includes its dependencies, such that there needs to
> exist in the META-INF folder of the generated release jar a spring.handlers
> containing a combination of all the spring.handlers encountered in all the
> dependency jars collected and included.

We hack around this using a bit of groovy scripting in Mule. See the
pom.xml in
http://svn.codehaus.org/mule/branches/mule-3.2.x/distributions/embedded/
(the groovy script resides there, too).

-dirk

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