Thanks for the clearing Brian,
i have read your tutorial and it seems a good approach, however i thought
about an alternative aproach maybe you can give me your opinion about it.
What i want to archive is simply that i fetch every duplicate configuration
within my projects make a parent pom and inherit those things to them.
With this i will save redundency and i think my configuration files will be
better to read.
My problem was that with this aproach i could not set the path for a custom
xml file which would contain my checkstyle rules within the parents
reporting node, because when i inherited the xml file which was reachable in
the parent is not in the children.
For example in my parent project the custom.xml file (for checkstyle) was in
src/main/resources and my parent pom referenced to it. When inherited this
for the child, the child will look in his own src/main/resources and not
into the parents one which is pretty clear will result into a file not found
exception unless i inherit somehow those xml files too.
So my first guess was i need to somehow inherit those xml files too or make
them available on compile/run time which i thought would work as i descirbed
in my first posting, the problem is that i now found out (with your help)
that it isnt possible, because i have to use packaging pom and can not
provide a jar.
However i could just do it like this:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<configuration>
<configLocation>file:////../checkstyle.xml</configLocation>
</configuration>
</plugin>
placing the custom checkstyle.xml on a server so every project which
inherits this can access it.
I don't know if this aproach brings any disadvantages or is recommendable
for my use case.
Thanks kukudas.
Brian E Fox wrote:
>
> You found a bug in 2.1-SNAPSHOT. The parents must be pom packaging types.
>
> If you want to share checkstyle, just bundle it into a jar with assembly,
> and then you can add that jar as a dependency to your checkstyle config.
> You
> don't need to inherit from the checkstyle jar itself, Checkstyle will find
> the xml on the classpath. I wrote some examples about this here:
> http://blogs.sonatype.com/people/2008/04/how-to-share-resources-across-proje
> cts-in-maven/
>
> http://blogs.sonatype.com/people/2008/04/how-to-override-a-plugins-dependenc
> y-in-maven/
>
> --Brian
>
> On 1/20/09 8:03 AM, "kukudas" <[email protected]> wrote:
>
>> Hi,
>>
>> i have a problem and i hope somebody can help me. I'm kinda new to this
>> things so maybe my approach is generaly wrong.
>>
>> i'm having a parent for example like this:
>>
>> <modelVersion>4.0.0</modelVersion>
>> <groupId>org.test</groupId>
>> <artifactId>parent</artifactId>
>> <version>1</version>
>> <build>
>> <plugin>
>> <groupId>org.apache.maven.plugins</groupId>
>> <artifactId>maven-checkstyle-plugin</artifactId>
>> <dependencies>
>> <dependency>
>> <groupId>${pom.parent.groupId}</groupId>
>> <artifactId>${pom.parent.artifactId}</artifactId>
>> <version>${pom.parent.version}</version>
>> </dependency>
>> </dependencies>
>> </plugin>
>> <reporting>
>> <plugin>
>> <groupId>org.apache.maven.plugins</groupId>
>> <artifactId>maven-checkstyle-plugin</artifactId>
>> <configuration>
>> <configLocation>checkstyle.xml</configLocation>
>> </configuration>
>> </plugin>
>> </plugins>
>> </reporting>
>> </project>
>>
>> And a child like this:
>>
>> <parent>
>> <groupId>org.test</groupId>
>> <artifactId>parent</artifactId>
>> <version>1</version>
>> </parent>
>>
>> <modelVersion>4.0.0</modelVersion>
>> <groupId>org.test</groupId>
>> <artifactId>child</artifactId>
>>
>> When i use Maven 2.0.9 i get the error that parent packaging has to be
>> pom.
>> But it has to be jar so my child can access the checkstyle.xml which is
>> in
>> the parent projects resource folder.
>> With Maven 2.1-SNAPSHOT it works as expected (checkstyle runs with my
>> rules
>> which are in the parents resource folder). Is there maybe a better way to
>> solve this or somehow make it work with both versions? I don't want to
>> use
>> packaging jar, run clean install for my parent and then change it to pom
>> so
>> that it will work with 2.0.9.
>>
>>
>> Thanks in advance
>>
>> kukudas
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>
>
--
View this message in context:
http://www.nabble.com/Maven-inheritence-works-with-2.1-SNAPSHOT-but-not-with-2.0.9-tp21562721p21579235.html
Sent from the Maven - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]