james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matthieu Baechler <mbaech...@linagora.com>
Subject Re: AW: james-server pom.xml missing scope test [unsigned]
Date Mon, 21 Mar 2016 21:23:57 GMT

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
> 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.


Matthieu Baechler

To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org

View raw message