How to force a change in a child pom

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

How to force a change in a child pom

Arnold Morein
I have created a series of POM files:

master-pom - contains all the various libraries, versions, scopes under the dependencyManagement section.

Then I created webapp-pom - contains a subset of those libraries, specific to building web applications, also under the dependencyManagement  section.

I then defined a specific EJB project (ee-cdi-webapp) based on webapp-pom that defines functionality desired in all applications. The dependencies are under dependencies section however. This project will become a required module in all EAR type projects.

Then the main project is defined with ee-cdi-webapp as the the parent; it contains an EAR, EJB and WAR modules. The EAR, EJB, and WAR projects are building and deploying just fine.

I then added a tiny dbutility project with a special class (and a main class to invoke it) to instantiate and therein test my Hibernate mappings, and initialize the database. This project has to be built into an executable jar.

I then created an assembly project for the dbuility project so that only the desired persistence.xml file is included. It builds the executable jar just fine, but MOST of the resources from the dbuility project are all still in the PROVIDED scope.

I do not understand how to forcibly change the scope of the inherited dependencies to COMPILE this far down stream.

Can anyone offer any guidance?

Reply | Threaded
Open this post in threaded view
|

RE: How to force a change in a child pom

Samuli Saarinen
Hi,

You can specify Maven assembly plugin to include provided scoped artifacts as described here: https://stackoverflow.com/a/14616643/7773647. There is also a sample of changing the scope using properties but seems more hacky to me.

br,
Samuli

From: Arnold Morein <[hidden email]>
Sent: 18. joulukuutata 2018 6:08
To: [hidden email]
Subject: How to force a change in a child pom

I have created a series of POM files:

master-pom - contains all the various libraries, versions, scopes under the dependencyManagement section.

Then I created webapp-pom - contains a subset of those libraries, specific to building web applications, also under the dependencyManagement  section.

I then defined a specific EJB project (ee-cdi-webapp) based on webapp-pom that defines functionality desired in all applications. The dependencies are under dependencies section however. This project will become a required module in all EAR type projects.

Then the main project is defined with ee-cdi-webapp as the the parent; it contains an EAR, EJB and WAR modules. The EAR, EJB, and WAR projects are building and deploying just fine.

I then added a tiny dbutility project with a special class (and a main class to invoke it) to instantiate and therein test my Hibernate mappings, and initialize the database. This project has to be built into an executable jar.

I then created an assembly project for the dbuility project so that only the desired persistence.xml file is included. It builds the executable jar just fine, but MOST of the resources from the dbuility project are all still in the PROVIDED scope.

I do not understand how to forcibly change the scope of the inherited dependencies to COMPILE this far down stream.

Can anyone offer any guidance?

Reply | Threaded
Open this post in threaded view
|

Re: How to force a change in a child pom

Anders Hammar
In reply to this post by Arnold Morein
It is possible to change the scope of a transitive dependency by defining
the artifact in dependencyManagement where you also specify the desired
scope.

/Anders

On Tue, Dec 18, 2018 at 5:08 AM Arnold Morein <[hidden email]>
wrote:

> I have created a series of POM files:
>
> master-pom - contains all the various libraries, versions, scopes under
> the dependencyManagement section.
>
> Then I created webapp-pom - contains a subset of those libraries, specific
> to building web applications, also under the dependencyManagement  section.
>
> I then defined a specific EJB project (ee-cdi-webapp) based on webapp-pom
> that defines functionality desired in all applications. The dependencies
> are under dependencies section however. This project will become a required
> module in all EAR type projects.
>
> Then the main project is defined with ee-cdi-webapp as the the parent; it
> contains an EAR, EJB and WAR modules. The EAR, EJB, and WAR projects are
> building and deploying just fine.
>
> I then added a tiny dbutility project with a special class (and a main
> class to invoke it) to instantiate and therein test my Hibernate mappings,
> and initialize the database. This project has to be built into an
> executable jar.
>
> I then created an assembly project for the dbuility project so that only
> the desired persistence.xml file is included. It builds the executable jar
> just fine, but MOST of the resources from the dbuility project are all
> still in the PROVIDED scope.
>
> I do not understand how to forcibly change the scope of the inherited
> dependencies to COMPILE this far down stream.
>
> Can anyone offer any guidance?
>
>
Reply | Threaded
Open this post in threaded view
|

Re: How to force a change in a child pom

Arnold Morein
In reply to this post by Arnold Morein
Thanks for that. I now have the dbutility project getting all the required components exported into the executable jar but for one tiny thing.

The META-INF/persistence.xml from the EJB project is a context for use in an EAR; it references a JNDI connection pool.

The one in the dbutility project is under a different name, connection parameters, and has the

<property name="hibernate.hbm2ddl.auto" value="create" />

statement so that Hibernate validates my mappings, exports the schema, and initializes some tables.

So, in the dbutility's assembly.xml file, I listed:

            <sources>
                 <fileSets>
                     <fileSet>
                         <excludes>
                             <exclude>%ant[**/persistence.xml]</exclude>
                         </excludes>
                     </fileSet>
                 </fileSets>
            </sources>

on the EJB project's moduleSet so its persistence.xml is NOT included and the one from the dbutility's moduleSet IS included from the next moduleSet.

The build runs w/o errors, but the exclusion is NOT happening.


On Dec 18, 2018, at 01:19 AM, Anders Hammar <[hidden email]> wrote:

It is possible to change the scope of a transitive dependency by defining
the artifact in dependencyManagement where you also specify the desired
scope.

/Anders

On Tue, Dec 18, 2018 at 5:08 AM Arnold Morein <[hidden email]>
wrote:

I have created a series of POM files:

master-pom - contains all the various libraries, versions, scopes under
the dependencyManagement section.

Then I created webapp-pom - contains a subset of those libraries, specific
to building web applications, also under the dependencyManagement section.

I then defined a specific EJB project (ee-cdi-webapp) based on webapp-pom
that defines functionality desired in all applications. The dependencies
are under dependencies section however. This project will become a required
module in all EAR type projects.

Then the main project is defined with ee-cdi-webapp as the the parent; it
contains an EAR, EJB and WAR modules. The EAR, EJB, and WAR projects are
building and deploying just fine.

I then added a tiny dbutility project with a special class (and a main
class to invoke it) to instantiate and therein test my Hibernate mappings,
and initialize the database. This project has to be built into an
executable jar.

I then created an assembly project for the dbuility project so that only
the desired persistence.xml file is included. It builds the executable jar
just fine, but MOST of the resources from the dbuility project are all
still in the PROVIDED scope.

I do not understand how to forcibly change the scope of the inherited
dependencies to COMPILE this far down stream.

Can anyone offer any guidance?


Reply | Threaded
Open this post in threaded view
|

RE: How to force a change in a child pom

Samuli Saarinen
You could try including <useStrictFiltering>true</useStrictFiltering> in the fileSet to see if the pattern actually matches anything. Running with mvn -X might also give some insight of what is actually happening during assembly.

br,
Samuli

From: Arnold Morein <[hidden email]>
Sent: 18. joulukuutata 2018 23:58
To: Maven Users List <[hidden email]>
Subject: Re: How to force a change in a child pom

Thanks for that. I now have the dbutility project getting all the required components exported into the executable jar but for one tiny thing.

The META-INF/persistence.xml from the EJB project is a context for use in an EAR; it references a JNDI connection pool.

The one in the dbutility project is under a different name, connection parameters, and has the

<property name="hibernate.hbm2ddl.auto" value="create" />

statement so that Hibernate validates my mappings, exports the schema, and initializes some tables.

So, in the dbutility's assembly.xml file, I listed:

            <sources>
                 <fileSets>
                     <fileSet>
                         <excludes>
                             <exclude>%ant[**/persistence.xml]</exclude>
                         </excludes>
                     </fileSet>
                 </fileSets>
            </sources>

on the EJB project's moduleSet so its persistence.xml is NOT included and the one from the dbutility's moduleSet IS included from the next moduleSet.

The build runs w/o errors, but the exclusion is NOT happening.


On Dec 18, 2018, at 01:19 AM, Anders Hammar <[hidden email]<mailto:[hidden email]>> wrote:
It is possible to change the scope of a transitive dependency by defining
the artifact in dependencyManagement where you also specify the desired
scope.

/Anders

On Tue, Dec 18, 2018 at 5:08 AM Arnold Morein <[hidden email]<mailto:[hidden email]>>
wrote:


I have created a series of POM files:

master-pom - contains all the various libraries, versions, scopes under
the dependencyManagement section.

Then I created webapp-pom - contains a subset of those libraries, specific
to building web applications, also under the dependencyManagement section.

I then defined a specific EJB project (ee-cdi-webapp) based on webapp-pom
that defines functionality desired in all applications. The dependencies
are under dependencies section however. This project will become a required
module in all EAR type projects.

Then the main project is defined with ee-cdi-webapp as the the parent; it
contains an EAR, EJB and WAR modules. The EAR, EJB, and WAR projects are
building and deploying just fine.

I then added a tiny dbutility project with a special class (and a main
class to invoke it) to instantiate and therein test my Hibernate mappings,
and initialize the database. This project has to be built into an
executable jar.

I then created an assembly project for the dbuility project so that only
the desired persistence.xml file is included. It builds the executable jar
just fine, but MOST of the resources from the dbuility project are all
still in the PROVIDED scope.

I do not understand how to forcibly change the scope of the inherited
dependencies to COMPILE this far down stream.

Can anyone offer any guidance?