Maven2: change execution during reactor build - deployment

I have a multi-module project (5 modules) running on maven2 and I'd like to do the following:
Run MVN clean deploy in 3 modules
run MVN clean test in 2 modules.
Is there a way to accomplish this with a single Maven execution?
The goal is to avoid deploying modules which aren't needed by any other projects making the build faster.

You can control which projects would skip deploy or test build lifecycle phases using profiles and set skip property in maven deploy and surefire plugins in those profiles in individual project.
However, deploy phase is the latest phase in the build lifecycle, so you will have to use something like Maven Invoker Plugin to spawn another Maven process.

Related

KIE Workbench Test Scenarios as a part of Maven build

In my current project we need to run Test Scenarios created in Workbench as a part of a Maven build. The final goal is to have these functional tests included to the continuous integration process.
We spent a couple of days trying to figure it out.
We opened a project that is created by Workbench in the .niogitfolder and are trying to run a maven goal.
But seems that maven goals like mvn clean install or mvn clean verify or mvn clean test don't run the Test Scenarios having a .scenario type at all.
Do you have any ideas on that?
Test scenarios are specific to kie-workbench. maven commands will not execute them during build. If you want tests to be executed during maven build then you have to write junit tests to check the execution of rules and processes.
there is currently work in progress on new version of scenarios in the kie-workbench. See the list of tasks. I would recommend you to bring this requirement there.

Eclipse execute Maven build with tests

In simple words: How to runs in eclipse tests with building process (as simple as possible)?
I want to execute test defined in pom with every maven build. Currently all is build, but none test is run. When I execute maven test it runs test, but during build it only builds.
How can I add this phase to eclipse build process?
I already read Eclipse Maven Build and Test with One Button, and it is close to optimal, still I would like to run tests with build to be more TDD.
My solution(might not be optimal):
require maven runpath
Go to Project -> Builders
Add new Program
In Edit configuration enter (as on picture):
Location: your/maven/path
arguments: test -f /yourProjectPomPath/pom.xml
As on picture tab Build Options -> Check(click) During auto builds option select
Save changes and check if all works

Eclipse detects cycle in build path, maven does not

Eclipse gives me the following errors when building:
A cycle was detected in the build path of project 'com.X'. The cycle consists of projects {com.Y, com.Y}
A cycle was detected in the build path of project 'com.Y'. The cycle consists of projects {com.X, com.Y}
However, maven builds totally fine from the command line with "mvn clean install" and manual inspection of the POMs indicated that com.X depends on com.Y but com.Y does not depend on com.X.
Any idea what might cause this?
eclipse and maven are using different build configuration files, one (eclipse) contains circular dependency, another (maven) does not.

How to setup Eclipse for building a multiple project application?

I have a workspace with 6 projects. All of the projects except the main one, are marked as libraries.
I need to configure the main project to build without build path errors and to include the jars of the other 5 in the apk.
How can this be done?
If you're looking to produce a runtime jar with the other libs rolled in I suggest you look at maven to manage your dependencies and builds.

Debugging maven junit tests with filtered resources?

We are using filtered testResources in JUnit-tests that are usually executed by the maven surefire plugin. That is, the pom contains a section
<build>
<testResources>
<testResource>
<directory>src/test/resources</directory>
<filtering>true</filtering>
</testResource>
</testResources>
...
How can I run such JUnit-tests in the debugger? If I execute the tests in eclipse the tests fail since the test resources are not filtered. If the filtered test resources would be written somewhere into the target directory, I could just use this as an additional source path - but this is not the case. If I try to run the maven build in eclipse with Debug As / maven test , the build does not stop in the breakpoints. Any other ideas?
There are several options. First you can run the test from the command line specifying maven.surefire.debug. Per default surefire tests are run in a forked JVM which means that if you just debug the maven process you won't get any stops in the test breakpoints. That's probably what you are seeing now. See also http://maven.apache.org/plugins/maven-surefire-plugin/examples/debugging.html
Othwerwise I would recommend to configure your project within the IDE as a maven project. If the project is configured as maven project the resource filtering will occur automatically prior to running the tests. That's at least how it works within Idea and I think Eclipse does the same with the right maven plugin installed.
You can also run the maven build once from the command line and then manually add the target/test-classes directory to your IDE configuration. Works, but is a little bit dodgy.
If I execute the tests in eclipse the tests fail since the test resources are not filtered.
Use m2eclipse and resources will get filtered inside Eclipse.