Hello Matthieu,
thanks for good and clear explanation.
One thing left:
>> The maven-scope test defines this behavior.
> Of course. If you have a look at a "product" project like
> server/container/cassandra-guice/ , you should not get any test artifact
> when creating the deployment artifact.
That is exactly the question I stumpled across:
For me, james-server is a product, the one we need.
If you have a look at the "james-server" project, in that pom.xml.
There is the dependency to elasticsearch test-jar.
<artifactId>apache-james-mailbox-elasticsearch</artifactId>
<type>test-jar</type>
But as you stated, this may have a goal, like async assertions.
I am (trying to) run maven in eclipse, so I do not have a command line.
As I run maven with
Goals: "clean compile package install"
-D: skipTests
I get:
[ERROR] Failed to execute goal on project james-server-mailets: Could not
resolve dependencies for project
org.apache.james:james-server-mailets:bundle:3.0.0-beta5-SNAPSHOT: Failure to
find org.apache.james.protocols:protocols-managesieve:jar:tests:1.6.4-SNAPSHOT
in http://repository.apache.org/snapshots was cached in the local repository,
resolution will not be reattempted until the update interval of
apache.snapshots has elapsed or updates are forced -> [Help 1]
Removing the test-jar from pom.xml fixes that problem.
Greetings
Bernd
-----Ursprüngliche Nachricht-----
Von: Matthieu Baechler [mailto:[email protected]]
Gesendet: Montag, 21. März 2016 22:24
An: [email protected]
Betreff: Re: AW: james-server pom.xml missing scope test [unsigned]
On 21/03/2016 16:23, Bernd Waibel wrote:
> Hi Matthieu,
>
> thanks for the nice response. I would like to follow the discussion.
>
> At first I just had a look at the pom.xml of the server project, searching to
> solve my maven problems.
> Only cassandra and elasticsearch do define test-jar without scope.
> All other test-jars have the <scope>test</scope>.
> So I thought: all projects should use this pattern.
> I think that the maven <scope>test</scope> defines the parts of an project,
> which should be used inside a phase "test", for testing an application. But
> not inside a phase "publish" or "compile" (except compile-test).
<scope>test</scope> import the dependency _to compile and run tests_,
that is, the code under src/test.
> At second there is another thing I do not understand:
> In the pom.xml of the james-server and in
> <artifactId>apache-james-mailbox-elasticsearch</artifactId>
> there is a dependency
> <dependency>
> <groupId>junit</groupId>
> <artifactId>junit</artifactId>
> <scope>test</scope>
> </dependency>
> Here you used the test scope.
> But this "junit" dependency is needed to compile the test-jar of
> elasticsearch inside server/pom.xml.
> Defining the test-jar without any scope leads to the fact, that compiling the
> server will fail inside the compile phase, as missing the junit (and others),
> cause junit is not defined inside the compile phase.
> Is this correct? Remember: I am not a maven expert. ;-)
test-jar contains compiled code from src/test, it uses every artifacts
without any scope and also artifacts with test scope.
All these dependencies are attached to the test-jar artifact and will be
imported recursively by any project depending on it, whatever the scope
it is imported in.
Here is an example.
apache-james-mailbox-elasticsearch project generates two artifacts :
1/ apache-james-mailbox-elasticsearch
2/ apache-james-mailbox-elasticsearch test-jar
1/ doesn't use junit to compile. it doesn't define junit as a dependency.
2/ need junit to compile (and will get it from its dependencies), it
declares junit as a dependency and when apache-james-mpt-smtp-cassandra
project import it, it gets automatically junit as a dependency.
> Shouldn't every "test" dependencies use the same <scope>?
Not always. Sometime you use awaitility for production code, sometime
for async assertions for example.
> At third, I had a look on this because we need to deploy it. That is the
> "architecture" side of this question. When deploying an application, I like
> it small. So we try to get rid of "debug" and "test" code, if we push our
> product to our customers. They will never need to test or debug "our"
> application.
> So I like it to have a "test" deployment, and a "runtime" deployment.
> The maven-scope test defines this behavior.
Of course. If you have a look at a "product" project like
server/container/cassandra-guice/ , you should not get any test artifact
when creating the deployment artifact.
>
> At last, the problem which caused the question:
> I just could not get the "james-server" to compile. Not inside eclipse.
> One reason is, that some test-classes won't compile.
> This is currently a "managesieve" error, exactly, not a elasticsearch
> problem, as I did find out.
You should just refresh your SNAPSHOT dependencies (under eclipse, you
can find this option under Maven -> Update Projet)
> But test-classes should not be critical for running James (IMO).
> But currently it is, because James won't run without test-classes.
It should not be true.
> So the test-classes may be a show-stopper.
>
> As I understand, maven will currently use the <test-jar> dependency, if
> running through the package phase of james-server, cause it does not have any
> scope.
> The -Dskiptests will not work, cause the artifact is not of scope test.
> Furthermore the test-jar is not available on the apache repo
> https://repository.apache.org/content/groups/snapshots/org/apache/james/
> It should be.
I don't think so.
> But that is another problem.
>
> Currently I just comment out all test-jar directives in server/pom.xml, to
> get maven to package my james server. This is ok for me. But I just like to
> understand.
>
>
> Just my part of thoughts, and not worth a jira ticket.
It's not "maven" that want to have tests to compile, it's you that ask
for. If you want to compile only production code, you can do something
like :
mvn -am -pl server/container/cassandra-guice -DskipTests
When you simply call maven without any project (here, I use -am -pl to
list projects I want to compile), every single project compiles, even
test projects, so you have to filter what you want.
I hope my answer helps.
Cheers,
--
Matthieu Baechler
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]