4

I’m using Maven 3.2.2. In one of my child modules, I have this dependency …

 <dependency> <groupId>org.mainco.subco</groupId> <artifactId>core</artifactId> <version>${project.parent.version}</version> <type>test-jar</type> <scope>test</scope> </dependency> 

Is there a way to get Maven to ignore this dependency when running my release plugin if I specify “-DskipTests” (or some other skip test option)? Here are my release plugin goals …

-Darguments="-DskipTests -P prod -Dcloudbees" -Dresume=false release:prepare release:perform 

I realize that I could work on the problem of getting that dependency built and ready to go, but this question specifically deals with Maven ignoring dependencies scoped as “test” when I do not intend to run any tests.

Thanks, - Dave

1
  • Have you solved this problem? Commented Mar 16, 2016 at 7:33

1 Answer 1

3

Before Maven starts executing the goals, it creates a buildplan. It'll go through all dependencies, no matter the scope. However, you can trick it with a profile triggered by a property. Be aware, profiles are often used for the wrong reasons (I noticed the prod-profile, that's such an example: configuration doesn't belong in the artifact. That's another discussion and there are enough threads about it).

In this case:

<profile> <activation> <property>skipTests</property> <value>!true<property> </activation> <dependencies> <!-- your test-scoped dependency --> </dependencies> </profile> 

So yes it can, but it is probably better to have this dependency available. If someone else checks out this code and tries to build it, it'll fail by default, right? That's not what users expect.

Sign up to request clarification or add additional context in comments.

1 Comment

<value>!true<property> isn't valid xml

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.