You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Zac Thompson <za...@gmail.com> on 2010/12/15 08:12:04 UTC

Re: POM inheritance breaks build

I posted a reply to this on stackoverflow, since that's where you
included more details.  The bottom line was that the properties are
*not* defined in A or B, only in *profiles* in A and B.  And there's
the rub: those profiles do not apply when building C, and the property
is not defined anywhere in C's pom.

On Sat, Nov 13, 2010 at 11:42 AM, cowwoc <co...@bbs.darktech.org> wrote:
>
> Hi,
>
> I've posted a simple testcase at
> http://stackoverflow.com/questions/4171222/maven-depending-on-inheriting-artifact-causes-build-error
> that demonstrates how POM inheritance causes builds to break.
>
> Given three POM files:
>
>    * C depends on B.
>    * B inherits from A.
>    * I can build A and B
>    * C fails to resolve properties defined in A or B, and as a result fails
> to locate its transitive dependencies. The build breaks.
>
> Please help!
>
> Thanks,
> Gili

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


Re: POM inheritance breaks build

Posted by cowwoc <co...@bbs.darktech.org>.

cowwoc wrote:
> 
> 
> Jörg Schaible-3 wrote:
>> 
>> The point is that it is platform dependent - the platform your developer
>> is 
>> using. A profile should not be used to define dependencies - at least if 
>> those should be transitively inherited. It simply does not work in the
>> way 
>> most people assume. It is not inherited anyway, therefore you have to
>> define 
>> it already twice (in A and B). This does not scale also.
>> 
>> What you might try is to define a swt pom (or package type pom) for all 
>> platforms like:
>> 
>> ...
>>   <groupId>com.eclipse</groupId>
>>   <artifactId>swt-generic</artifactId>
>>   <version>3.6.1</version>
>>   <packaging>pom</packaging>
>> 
>>   <profiles>
>>     <profile>
>>       <id>win32</id>
>>       <dependencies>
>>         <groupId>com.eclipse</groupId>
>>         <artifactId>swt</artifactId>
>>         <version>3.6.1</version>
>>         <classifier>win32-x86</classifier>
>>       </dependencies>
>>     </profile>
>>     ...
>>   </profiles>
>> 
>> and refer that everywhere you need it as provided:
>> 
>> ..
>>     <dependency>
>>       <groupId>com.eclipse</groupId>
>>       <artifactId>swt-generic</artifactId>
>>       <version>3.6.1</version>
>>       <type>pom</type>
>>       <scope>provided</scope>
>>     </dependency>
>> ..
>> 
>> Your developers may actually set their default in the settings.xml:
>> 
>>   <activeProfiles>
>>     <activeProfile>win32</activeProfile>
>>     ...
>>   </activeProfiles>
>>   <profiles>
>>     <profile>
>>       <id>win32</id>
>>     </profile>
>>     ...
>>   </profiles>
>> 
>> The provided scope prevents that a special one is taken and you have to 
>> select the appropriate one(s) when packaging your app e.g. with the
>> assembly 
>> plugin.
>> 
> 
> Hi Jörg,
> 
> I followed your instructions but I don't understand how:
> 
>   <activeProfiles>
>     <activeProfile>win32</activeProfile>
>     ...
>   </activeProfiles>
>   <profiles>
>     <profile>
>       <id>win32</id>
>     </profile>
>     ...
>   </profiles>
> 
> leads to the inclusion of the Windows-specific SWT library. It doesn't
> seem to activate the "win32" profile in the SWT project. Any ideas?
> 
> Gili
> 

I should clarify: I can see how <activeProfile> causes the SWT project to
build correctly (generating a Windows JAR file). What I can't see is how to
get that JAR file to show up as a dependency in the project that depends on
SWT.

One final complication: is there a way for me to define ${swt.classifier} in
the SWT project and have it  show in the child project? My first use-case is
to include SWT as a normal dependency. My second use-case is to use
maven-unpack-plugin to download and unpack the JAR file. To do the latter, I
need the classifier name in the child project.

Thanks,
Gili
-- 
View this message in context: http://maven.40175.n5.nabble.com/POM-inheritance-breaks-build-tp3263869p3309568.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: POM inheritance breaks build

Posted by cowwoc <co...@bbs.darktech.org>.

Jörg Schaible-3 wrote:
> 
> The point is that it is platform dependent - the platform your developer
> is 
> using. A profile should not be used to define dependencies - at least if 
> those should be transitively inherited. It simply does not work in the way 
> most people assume. It is not inherited anyway, therefore you have to
> define 
> it already twice (in A and B). This does not scale also.
> 
> What you might try is to define a swt pom (or package type pom) for all 
> platforms like:
> 
> ...
>   <groupId>com.eclipse</groupId>
>   <artifactId>swt-generic</artifactId>
>   <version>3.6.1</version>
>   <packaging>pom</packaging>
> 
>   <profiles>
>     <profile>
>       <id>win32</id>
>       <dependencies>
>         <groupId>com.eclipse</groupId>
>         <artifactId>swt</artifactId>
>         <version>3.6.1</version>
>         <classifier>win32-x86</classifier>
>       </dependencies>
>     </profile>
>     ...
>   </profiles>
> 
> and refer that everywhere you need it as provided:
> 
> ..
>     <dependency>
>       <groupId>com.eclipse</groupId>
>       <artifactId>swt-generic</artifactId>
>       <version>3.6.1</version>
>       <type>pom</type>
>       <scope>provided</scope>
>     </dependency>
> ..
> 
> Your developers may actually set their default in the settings.xml:
> 
>   <activeProfiles>
>     <activeProfile>win32</activeProfile>
>     ...
>   </activeProfiles>
>   <profiles>
>     <profile>
>       <id>win32</id>
>     </profile>
>     ...
>   </profiles>
> 
> The provided scope prevents that a special one is taken and you have to 
> select the appropriate one(s) when packaging your app e.g. with the
> assembly 
> plugin.
> 

Hi Jörg,

I followed your instructions but I don't understand how:

  <activeProfiles>
    <activeProfile>win32</activeProfile>
    ...
  </activeProfiles>
  <profiles>
    <profile>
      <id>win32</id>
    </profile>
    ...
  </profiles>

leads to the inclusion of the Windows-specific SWT library. It doesn't seem
to activate the "win32" profile in the SWT project. Any ideas?

Gili
-- 
View this message in context: http://maven.40175.n5.nabble.com/POM-inheritance-breaks-build-tp3263869p3309523.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: POM inheritance breaks build

Posted by Jörg Schaible <jo...@scalaris.com>.
Hi Gili,

cowwoc wrote:

> 
> 
> Jörg Schaible-3 wrote:
>> 
>> cowwoc wrote:
>> 
>>> 
>>> Hi Zac,
>>> 
>>> I added:
>>> 
>>> <properties>
>>> <swt.classifier>win32-x86</swt.classifier>
>>> </properties>
>> 
>> You can define this property in your settings.xmll in the appropriate
>> profile.
>> 
>> - Jörg
>> 
> 
> Jörg,
> 
> Isn't one of the main selling points of Maven the ability to include
> transitive dependencies with little effort? Now you're telling me that not
> only do I have to explicitly deal with each transitive dependency, I also
> have to tell all my developers to modify their settings.xml file. One
> person at a time.
> 
> ... Is this as good as it gets? ... Really?! Surely there is a better way?

The point is that it is platform dependent - the platform your developer is 
using. A profile should not be used to define dependencies - at least if 
those should be transitively inherited. It simply does not work in the way 
most people assume. It is not inherited anyway, therefore you have to define 
it already twice (in A and B). This does not scale also.

What you might try is to define a swt pom (or package type pom) for all 
platforms like:

...
  <groupId>com.eclipse</groupId>
  <artifactId>swt-generic</artifactId>
  <version>3.6.1</version>
  <packaging>pom</packaging>

  <profiles>
    <profile>
      <id>win32</id>
      <dependencies>
        <groupId>com.eclipse</groupId>
        <artifactId>swt</artifactId>
        <version>3.6.1</version>
        <classifier>win32-x86</classifier>
      </dependencies>
    </profile>
    ...
  </profiles>

and refer that everywhere you need it as provided:

..
    <dependency>
      <groupId>com.eclipse</groupId>
      <artifactId>swt-generic</artifactId>
      <version>3.6.1</version>
      <type>pom</type>
      <scope>provided</scope>
    </dependency>
..

Your developers may actually set their default in the settings.xml:

  <activeProfiles>
    <activeProfile>win32</activeProfile>
    ...
  </activeProfiles>
  <profiles>
    <profile>
      <id>win32</id>
    </profile>
    ...
  </profiles>

The provided scope prevents that a special one is taken and you have to 
select the appropriate one(s) when packaging your app e.g. with the assembly 
plugin.

- Jörg


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


Re: POM inheritance breaks build

Posted by cowwoc <co...@bbs.darktech.org>.

Jörg Schaible-3 wrote:
> 
> cowwoc wrote:
> 
>> 
>> Hi Zac,
>> 
>> I added:
>> 
>> <properties>
>> <swt.classifier>win32-x86</swt.classifier>
>> </properties>
> 
> You can define this property in your settings.xmll in the appropriate 
> profile.
> 
> - Jörg
> 

Jörg,

Isn't one of the main selling points of Maven the ability to include
transitive dependencies with little effort? Now you're telling me that not
only do I have to explicitly deal with each transitive dependency, I also
have to tell all my developers to modify their settings.xml file. One person
at a time.

... Is this as good as it gets? ... Really?! Surely there is a better way?

Gili
-- 
View this message in context: http://maven.40175.n5.nabble.com/POM-inheritance-breaks-build-tp3263869p3308116.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: POM inheritance breaks build

Posted by Jörg Schaible <jo...@scalaris.com>.
cowwoc wrote:

> 
> Hi Zac,
> 
> I added:
> 
> <properties>
> <swt.classifier>win32-x86</swt.classifier>
> </properties>

You can define this property in your settings.xmll in the appropriate 
profile.

- Jörg


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


Re: POM inheritance breaks build

Posted by cowwoc <co...@bbs.darktech.org>.
Hi Zac,

I added:

		<properties>
			<swt.classifier>win32-x86</swt.classifier>
		</properties>

to project C but Maven still complains:

Failed to execute goal on project C: Could not resolve dependencies for
project com.foo:C:jar:1.0-SNAPSHOT: Failure to find
org.eclipse.swt:swt:jar:${swt.classifier}:3.6.1 in [...] was cached in the
local repository, resolution will not be reattempted until the update
interval of amaya.dependencies has elapsed or updates are forced -> [Help 1]

I don't think property resolution is working as you expect it. I am using
Maven 3.0.1.

Gili


Zac Thompson wrote:
> 
> I posted a reply to this on stackoverflow, since that's where you
> included more details.  The bottom line was that the properties are
> *not* defined in A or B, only in *profiles* in A and B.  And there's
> the rub: those profiles do not apply when building C, and the property
> is not defined anywhere in C's pom.
> 
> On Sat, Nov 13, 2010 at 11:42 AM, cowwoc <co...@bbs.darktech.org> wrote:
>>
>> Hi,
>>
>> I've posted a simple testcase at
>> http://stackoverflow.com/questions/4171222/maven-depending-on-inheriting-artifact-causes-build-error
>> that demonstrates how POM inheritance causes builds to break.
>>
>> Given three POM files:
>>
>>    * C depends on B.
>>    * B inherits from A.
>>    * I can build A and B
>>    * C fails to resolve properties defined in A or B, and as a result
>> fails
>> to locate its transitive dependencies. The build breaks.
>>
>> Please help!
>>
>> Thanks,
>> Gili
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 
> 
> 

-- 
View this message in context: http://maven.40175.n5.nabble.com/POM-inheritance-breaks-build-tp3263869p3308016.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