Generating/copying resources before test stage

2010-05-26 Thread Ernst de Haan
How do I generate  copy the manifest file before the unit tests are executed?

I've got a unit test that tests code that needs to read the 
META-INF/MANIFEST.MF file, but when I run mvn test the classes are compiled, 
but the manifest file is not generated yet...

Cheers,


Ernst

Note: I previously asked a similar question on this forum about using the JAR. 
However, I decided I do not want to depend on the package from my unit tests, 
just on the resources (or at least the manifest file).
-
To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
For additional commands, e-mail: users-h...@maven.apache.org



Re: Sharing a version among different modules

2010-05-25 Thread Ernst de Haan

Thanks, Nicola. Interesting alternative!

So if I understand you correctly, you have version numbers on the  
aggregator and on modules below that, but you just keep those to a  
fixed vale (say 0) and use the root parent version to the outside  
world?


Cheers,


Ernst de Haan

Op 25 mei 2010 om 14:28 heeft Nicola Musatti nicola.musa...@objectway.it 
 het volgende geschreven:\


I keep all version numbers in the dependencyManagement section of my  
parent POM, which is different from my aggregator POM and is parent  
to the aggregator and all its modules. In this way I specify each  
version exactly once. Something like:


dependencyManagement
dependencies
dependency
groupIdbouncycastle/groupId
artifactIdbcprov-jdk13/artifactId
version140/version
/dependency
/dependencyManagement

dependencyManagement is a direct child of the project element.

Cheers,
Nicola Musatti

Ernst de Haan wrote:

- in the parent pom.xml, to denote the project version


you need this



- in each module, to denote the module version

just leave out the version and it will inherit it from the parent  
pom




- in each module's reference to the parent


you need this



- in each module's reference to a sibling


   dependency
 groupId${project.parent.groupId}/groupId
 artifactIdsibling-one/artifactId
 version${project.parent.version}/version
   /dependency

Thanks a lot Kristian, this indeed improves the situation a *lot*.  
Instead of 10 references for 3 modules, I am now able to reduce it  
to:


1 + (1 per module)

However, I'll continue my quest to further reduction of  
replication, as my ultimate goal is still to have the version  
number in one place. Perhaps XInclude or so will do the trick.


Thanks heaps!


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






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



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



Re: Sharing a version among different modules

2010-05-25 Thread Ernst de Haan

Nicola and Todd,

This is *exactly* what I was looking for! The article Todd mentioned  
explains it very well, both the challenges and the solutions.


Cheers!

Ernst de Haan

Op 25 mei 2010 om 15:03 heeft Thiessen, Todd (Todd) tthies...@avaya.com 
 het volgende geschreven:\


I use this method described by Nicole as well. Its described in  
great detail in the definitive guide.


http://www.sonatype.com/books/mvnex-book/reference/optimizing-sect-dependencies.html


-Original Message-
From: Ernst de Haan [mailto:er...@ernstdehaan.com]
Sent: Tuesday, May 25, 2010 8:58 AM
To: Maven Users List
Cc: Maven Users List
Subject: Re: Sharing a version among different modules

Thanks, Nicola. Interesting alternative!

So if I understand you correctly, you have version numbers on
the aggregator and on modules below that, but you just keep
those to a fixed vale (say 0) and use the root parent
version to the outside world?

Cheers,


Ernst de Haan

Op 25 mei 2010 om 14:28 heeft Nicola Musatti
nicola.musa...@objectway.it   het volgende geschreven:\


I keep all version numbers in the dependencyManagement

section of my

parent POM, which is different from my aggregator POM and

is parent to

the aggregator and all its modules. In this way I specify

each version

exactly once. Something like:

dependencyManagement
dependencies
dependency
groupIdbouncycastle/groupId
artifactIdbcprov-jdk13/artifactId
version140/version
/dependency
/dependencyManagement

dependencyManagement is a direct child of the project element.

Cheers,
Nicola Musatti

Ernst de Haan wrote:

- in the parent pom.xml, to denote the project version


you need this



- in each module, to denote the module version


just leave out the version and it will inherit it from the parent
pom



- in each module's reference to the parent


you need this



- in each module's reference to a sibling


  dependency
groupId${project.parent.groupId}/groupId
artifactIdsibling-one/artifactId
version${project.parent.version}/version
  /dependency


Thanks a lot Kristian, this indeed improves the situation

a *lot*.

Instead of 10 references for 3 modules, I am now able to reduce it
to:

   1 + (1 per module)

However, I'll continue my quest to further reduction of

replication,

as my ultimate goal is still to have the version number in

one place.

Perhaps XInclude or so will do the trick.

Thanks heaps!


Ernst


-

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








-

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



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



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



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



Unit tests depending on manifest

2010-05-24 Thread Ernst de Haan
How can I make sure the manifest file gets generated before the unit tests are 
executed?

My use case is:
- a Java code base, under src/main/java
- unit tests under src/test/java
- pom.xml specifies packaging jar - JUnit 4.8.1 is a dependency
- Java code uses a property from the manifest to determine meta data (library 
version)
- Maven automatically generates the correct manifest file
- the unit tests attempt to validate that Java code, but the manifest file is 
not generated, it's only part of the JAR

Any suggestions?

Note that I'm new to Maven, but I used shell scripts and Ant build files a lot.

FYI, here is the actual code and POM:
http://github.com/znerd/logdoc/blob/master/base/src/main/java/org/znerd/logdoc/Library.java
http://github.com/znerd/logdoc/blob/master/base/src/test/java/org/znerd/logdoc/LibraryTest.java
http://github.com/znerd/logdoc/blob/master/base/pom.xml

Cheers,


Ernst de Haan

Re: Unit tests depending on manifest

2010-05-24 Thread Ernst de Haan
Wayne,


 How can I make sure the manifest file gets generated before the unit tests 
 are executed?
 
 - the unit tests attempt to validate that Java code, but the manifest file 
 is not generated, it's only part of the JAR
 
 Instead of running that test in this module's build, add another
 module alongside it that depends on this artifact, and run this test
 there. It will bring in the jar which, as you said, has the manifest
 in it. You will need a parent pom as well over both modules, and
 always build your project from the parent.

Brilliant! Thank you for he advice, this is indeed what I will do, I'll add 
another module.

Note that I'm new to Maven, I typically use Ant (and an occasional shell 
script). Although this approach seems the most logical, given the fixed model 
Maven enforces, it does give the impression that it makes me go against the 
basic principle Maven appears to herald, which is that one (sub-)project is a 
contained entity, self-sufficient, including all resources required to build 
and test the main codebase.

What I find in (a few days) practice, is that I need to add an extra module in 
multiple cases:
- to test code that depends on the manifest
- to test plugin code, since that needs to be compiled before the plugin can be 
accessed by Maven

/me ponders

But hey, thanks for giving me an easy way out that is very acceptable (at the 
least).

Cheers,


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



Sharing a version among different modules

2010-05-24 Thread Ernst de Haan
How do I share one version number across multiple module (subprojects)?

I have one parent pom.xml referencing 3 modules and -believe it or not- I've 
got the version number in 10 different locations:
- in the parent pom.xml, to denote the project version
- in each module, to denote the module version
- in each module's reference to the parent
- in each module's reference to a sibling

Any suggestions for reducing the number of locations (preferably to 1) ?

PS. To see the project and the POMs, see http://github.com/znerd/logdoc

Cheers,


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



Re: Sharing a version among different modules

2010-05-24 Thread Ernst de Haan
 - in the parent pom.xml, to denote the project version
 you need this
 
 - in each module, to denote the module version
 just leave out the version and it will inherit it from the parent pom
 
 - in each module's reference to the parent
 you need this
 
 - in each module's reference to a sibling
dependency
  groupId${project.parent.groupId}/groupId
  artifactIdsibling-one/artifactId
  version${project.parent.version}/version
/dependency

Thanks a lot Kristian, this indeed improves the situation a *lot*. Instead of 
10 references for 3 modules, I am now able to reduce it to:

1 + (1 per module)

However, I'll continue my quest to further reduction of replication, as my 
ultimate goal is still to have the version number in one place. Perhaps 
XInclude or so will do the trick.

Thanks heaps!


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



Re: Sharing a version among different modules

2010-05-24 Thread Ernst de Haan
 But if you are using release plugin 
 http://maven.apache.org/plugins/maven-release-plugin/ for releasing versions, 
 same version numbers in poms are updating automatically. There is no need to 
 have only one.
 
 See 
 http://maven.apache.org/plugins/maven-release-plugin/prepare-mojo.html#autoVersionSubmodules

Martin, thanks a lot! This looks very promising.

/me goes off to do some more investigation and try things out...

Cheers,


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



Re: Unit tests depending on manifest

2010-05-24 Thread Ernst de Haan
 Instead of running that test in this module's build, add another
 module alongside it that depends on this artifact, and run this test
 there. It will bring in the jar which, as you said, has the manifest
 in it. You will need a parent pom as well over both modules, and
 always build your project from the parent.

Another question: How do I make the test-module use the *JAR* instead of just 
the classes?

Here's what I have done:
- create a separate base-test module with a separate POM that depends on the 
base module
- move all unit tests to the base-test module
- run mvn clean and then mvn test

What happens is:
- the classes get compiled for the base module (but no JAR is generated)
- the unit tests in base-test are executed, using the classes (not the JAR)
- the tests (obviously) fail

So I try forcing the JAR to be created, using mvn install, which works. But 
still the unit tests fail, because they appear to use the classes instead of 
the JAR...

Any hints to this next piece of the puzzle?


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



Re: Sharing a version among different modules

2010-05-24 Thread Ernst de Haan
 How do I share one version number across multiple module (subprojects)?
 
 Any suggestions for reducing the number of locations (preferably to 1) ?
 
 There's also the versions-maven-plugin...

Cheers, Wayne, the more options the better. I'll look at that as well.

Regards,


Ernst
-- trying to look at it the positive side of having to wade through more 
documentation ;-)
-
To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
For additional commands, e-mail: users-h...@maven.apache.org



Re: Unit tests depending on manifest

2010-05-24 Thread Ernst de Haan
 better off using maven-failsafe-plugin for that

Stephen, thanks for the pointer. Will give that a try.

I was getting nowhere (yet) with all sorts of variants of the snippet Kristian 
sent. An alternative route is welcomed :)

/me struggles on...

Cheers,


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



Re: Unit tests depending on manifest

2010-05-24 Thread Ernst de Haan
 better off using maven-failsafe-plugin for that


How do I know for sure verify is using my JAR?

I tried the failsafe plugin, but it still /appears/ to be using the classes, 
not the JAR, even from my new LibraryIT.java integration test. It does execute, 
but the test fails.

Here's my POM for the base module:
http://github.com/znerd/logdoc/blob/master/base/pom.xml

And here's the one for the base-test module:
http://github.com/znerd/logdoc/blob/master/base-test/pom.xml

Can I debug the failsafe plugin?


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