How to make Quarkus use local library classes - maven

I'm starting with Quarkus using Maven and can't seem to find a solution to this:
I have a Quarkus app with dependencies on the libraries A and B. Both are imported as "Modules" (not Maven modules!) in the IntelliJ IDEA project for my app.
When starting Quarkus in dev mode, it ignores the classes in target/ of A and B and instead loads them from the Maven repository. Therefore with every change in either A or B, I have to mvn install the respective library, so my Quarkus app uses the correct code.
Coming from Thorntail, this was not necessary. Is there a solution that doesn't require auto-installing A and B on every build and also makes HotSwap work for those libs?
Edit:
As #CrazyCoder requested, here's a minimal example of my pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>test</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<compiler-plugin.version>3.8.1</compiler-plugin.version>
<maven.compiler.parameters>true</maven.compiler.parameters>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<quarkus-plugin.version>1.8.3.Final</quarkus-plugin.version>
<quarkus.platform.version>1.8.3.Final</quarkus.platform.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-universe-bom</artifactId>
<version>${quarkus.platform.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy</artifactId>
</dependency>
<dependency>
<groupId>com.example</groupId>
<artifactId>A</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.example</groupId>
<artifactId>B</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
<version>${quarkus-plugin.version}</version>
<executions>
<execution>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
A and B are listed in IntelliJ IDEA under "Project Structure... > Modules > test > Dependencies" as Module Depenencies, not Maven Dependencies. So the code in A and B should be HotSwappable.

I eventually found the solution. As so often: Once you know it, it's trivial.
Open your run configuration, expand the Environment dropdown (only populated when an application module is selected) and check the option Resolve Workspace artifacts:

Related

Artifact[ejb:MoGEMSEJB:MoGEMSEJB] is not a dependency of the project error when adding Maven module

I am converting a Java EE project to a Maven project using IBM Rational Application Developer (RAD) which is based on Eclipse. IBM's instructions say to add the web project as a module in the EAR project but I am getting the error "Artifact[war:MoGEMS_WEB:MoGEMS_WEB] is not a dependency of the project." when I update the Maven project. I have included MoGEMS_WEB as a dependency and it is listed as a dependency when I click on the Dependencies tab in the EAR pom.xml file. The EAR pom file is:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>MoGEMSApp</groupId>
<artifactId>MoGEMSApp</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>ear</packaging>
<build>
<plugins>
<plugin>
<artifactId>maven-ear-plugin</artifactId>
<version>2.10</version>
<configuration>
<version>5</version>
<defaultLibBundleDir>lib</defaultLibBundleDir>
<security>
<security-role id="SecurityRole_1">
<role-name>Security Role</role-name>
</security-role>
</security>
<modules>
<webModule>
<groupId>MoGEMS_WEB</groupId>
<artifactId>MoGEMS_WEB</artifactId>
<contextRoot>/mogems</contextRoot>
</webModule>
</modules>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>MoGEMSEJBClient</groupId>
<artifactId>MoGEMSEJBClient</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>MoGEMSEJB</groupId>
<artifactId>MoGEMSEJB</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>MoGEMS_WEB</groupId>
<artifactId>MoGEMS_WEB</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>

Error: 'dependencies.dependency.version' must be a valid version but is

I have this parent POM file (hawaii-banner\pom.xml):
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>base</artifactId>
<groupId>org.sakaiproject</groupId>
<version>2.9.3</version>
<relativePath>../pom.xml</relativePath>
</parent>
<name>University of Hawaii Banner</name>
<groupId>edu.hawaii.sakai</groupId>
<artifactId>hawaii-banner</artifactId>
<version>${hawaii.banner.version}</version>
<packaging>pom</packaging>
<properties>
<downloadSources>true</downloadSources>
<downloadJavadocs>true</downloadJavadocs>
<hawaii.banner.version>2.5.0</hawaii.banner.version>
<uh-gatech.version>2.5.1</uh-gatech.version>
</properties>
<dependencies>
<dependency>
<groupId>org.sakaiproject.kernel</groupId>
<artifactId>sakai-kernel-api</artifactId>
<version>${sakai.kernel.version}</version>
</dependency>
<dependency>
<groupId>org.sakaiproject.kernel</groupId>
<artifactId>sakai-kernel-util</artifactId>
<version>${sakai.kernel.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.4</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<includes>
<include>**/*Test.java</include>
</includes>
<!-- Exclude by default the tests that use remote systems. -->
<excludes>
<exclude>**/*Test.java</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
<modules>
<module>api</module>
<module>impl</module>
<module>integration-test</module>
<module>pack</module>
<module>sections-impl</module>
</modules>
</project>
And this child POM file (hawaii-banner\api\pom.xml):
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>edu.hawaii.sakai</groupId>
<artifactId>hawaii-banner</artifactId>
<version>2.5.0</version>
<relativePath>../pom.xml</relativePath>
</parent>
<name>University of Hawaii Banner API</name>
<groupId>edu.hawaii.sakai</groupId>
<artifactId>hawaii-banner-api</artifactId>
<version>${hawaii.banner.version}</version>
<packaging>jar</packaging>
<properties>
<deploy.target>shared</deploy.target>
</properties>
<dependencies>
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
</dependency>
<dependency>
<groupId>edu.gatech.sakai</groupId>
<artifactId>uh-gatech-banner-api</artifactId>
<version>${uh-gatech.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
But I'm getting this error:
[ERROR] 'dependencies.dependency.version' for edu.gatech.sakai:uh-gatech-banner-api:jar must be a valid version but is '${uh-gatech.version}'. # edu.hawaii.sakai:hawaii-banner-api:${hawaii.banner.version}, C:\hawaii-sakai-2.9.3\sakai-src-2.9.3\hawaii-banner\api\pom.xml, line 26, column 16
I don't understand why I'm getting this error because uh-gatech.version is defined in the parent POM file, and <version>${uh-gatech.version}</version> used to be <version>2.5.1</version>, which worked.
I ran mvn clean install from the same directory as the parent POM file, and it didn't work.
If maven gives this error, it means that the child module does not recognize the parent properly. I've seen this happen with wrong versions.
You think you are defining the right parent, but you are not. As #jordan suggested, by eliminating the child-parent relationship, you can see it works.
You cannot define the version of a module to be a variable you defined in the same pom, and maven will not want on this.
Although you think it's 2.5.0, it's not...
I suggest you review this relationship definition in your project.
I hope this helps.

Estructuration of multi module project. how to packaging modules?

i'm creating the estructure of a multi modul project with maven.
The parent's pom:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven- 4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>cat.base.gpt</groupId>
<artifactId>gpt</artifactId>
<version>0.0.1</version> <!-- application version -->
<packaging>pom</packaging>
<name>gpt</name>
<parent>
<groupId>cat.base.baseframe</groupId>
<artifactId>projecte-pare-baseframe</artifactId>
<version>0.0.11.a</version>
</parent>
<modules>
<module>gpt.domini</module>
<module>gpt.ui</module>
<module>gpt.logica</module>
<module>gpt.ejb</module>
<module>gpt.ear</module>
</modules>
<dependencies>
<!-- dependencies pel testeig TDD -->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.7</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>1.9.5-rc1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.kubek2k</groupId>
<artifactId>springockito</artifactId>
<version>1.0.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.4</version>
<scope>provided</scope>
</dependency>
<!-- A més, en el cas de provatures UI, s'ha d'afegir la següent dependència:-->
<dependency>
<groupId>cat.base.baseframe</groupId>
<artifactId>baseframe-test-swf</artifactId>
<version>1.0.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Ok, first question, i put all the dependencies at paren's pom is this really correct?
and the most interesting part, i don't know hos to compile the grafic interfade project,(i call ui), it's better create a war or create and ear with all the necessary (ui+logica+domini+ejb) i 'm a litlle bit confused about that, i uset o work with projects already estructure created. I hope you to unsderstand my question, i put the rest of pom to keep an eye. ty.
pom's gpt.domini.
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>gpt</artifactId>
<groupId>cat.base.gpt</groupId>
<version>0.0.1</version>
</parent>
<groupId>cat.base.gpt.domini</groupId>
<artifactId>gpt.domini</artifactId>
<packaging>jar</packaging>
<name>gpt.domini</name>
<description>Definició del model de dades i de la façana del servei</description>
</project>
pom's gpt.ear
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>gpt</artifactId>
<groupId>cat.base.gpt</groupId>
<version>0.0.1</version>
</parent>
<groupId>cat.base.gtp.ear</groupId>
<artifactId>gpt.ear</artifactId>
<name>gpt.ear</name>
<packaging>ear</packaging>
<description>Paquet de l'aplicació J2EE</description>
<dependencies>
<dependency>
<groupId>${project.parent.groupId}</groupId>
<artifactId>${project.parent.artifactId}.domini</artifactId>
<version>${project.parent.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>${project.parent.groupId}</groupId>
<artifactId>${project.parent.artifactId}.ejb</artifactId>
<version>${project.parent.version}</version>
<type>ejb</type>
</dependency>
<dependency>
<groupId>${project.parent.groupId}</groupId>
<artifactId>${project.parent.artifactId}.logica</artifactId>
<version>${project.parent.version}</version>
<type>jar</type>
</dependency>
</dependencies>
</project>
pom's gpt.logica
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>gpt</artifactId>
<groupId>cat.base.gpt</groupId>
<version>0.0.1</version>
</parent>
<groupId>cat.base.gtp.logica</groupId>
<artifactId>gpt.logica</artifactId>
<name>climbing.logica</name>
<packaging>jar</packaging>
<description>Implementació del servei</description>
<dependencies>
<!-- de moment nomes el domini -->
<dependency>
<groupId>${project.parent.groupId}</groupId>
<artifactId>${project.parent.artifactId}.domini</artifactId>
<version>${project.parent.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
pom's gpt.ejb
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>gpt</artifactId>
<groupId>cat.base.gpt</groupId>
<version>0.0.1</version>
</parent>
<groupId>cat.base.gtp.ejb</groupId>
<artifactId>gpt.ejb</artifactId>
<name>gpt.ejb</name>
<packaging>ejb</packaging>
<description>Publicació d'un servei en forma EJB</description>
<dependencies>
<dependency>
<groupId>${project.parent.groupId}</groupId>
<artifactId>${project.parent.artifactId}.domini</artifactId>
<version>${project.parent.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>${project.parent.groupId}</groupId>
<artifactId>${project.parent.artifactId}.logica</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>${project.parent.groupId}</groupId>
<artifactId>${project.parent.artifactId}.logica</artifactId>
<version>${project.parent.version}</version>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.ejb</groupId>
<artifactId>ejb-api</artifactId>
<version>3.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>jboss</groupId>
<artifactId>jboss-annotations-ejb3</artifactId>
<version>4.2.2.GA</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>2.5.6</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.client</groupId>
<artifactId>jbossall-client</artifactId>
<version>4.2.3.GA</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
pom's gpt.logica
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>gpt</artifactId>
<groupId>cat.base.gpt</groupId>
<version>0.0.1</version>
</parent>
<groupId>cat.base.gtp.logica</groupId>
<artifactId>gpt.logica</artifactId>
<name>climbing.logica</name>
<packaging>jar</packaging>
<description>Implementació del servei</description>
<dependencies>
<!-- de moment nomes el domini -->
<dependency>
<groupId>${project.parent.groupId}</groupId>
<artifactId>${project.parent.artifactId}.domini</artifactId>
<version>${project.parent.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
pom's gpt.ui
here all the dependencies of spring-rich.faces..or better at parent's pom?
packaging like a war?? or inside de module ear?? ty.
Although there is already an accepted answer, I believe it worth to give more information to you as it seems to me that, both the questioner and the accepted answer got messed up with different concepts in Maven.
1) Aggregation vs Parent POM
There are two concepts in Maven often got mixed up. Aggregation (aka Multi-module) POM and Parent POM are something irrelevant, although it is fine to use one POM to serve for both purpose.
Multi-module project aims to describe the aggregation relationship between projects, so that we can build multiple related project as a whole, and all sub-projects are built in the same reactor. Parent project aims to provide shared project settings. It can even exists out of the project structure (e.g. I may have a company-wise parent POM)
Personally I recommend to have a multi-module POM only to declare the aggregation (hierarchy) of projects, and having a separate parent POM to be used to declare shared settings.
i.e.
my-proj // aggregation only
+ my-proj-parent // parent POM
+ my-proj-main
+ my-proj-web
+ my-proj-ear
2) Shared Dependency for POM vs in EAR
Again, these are two separate concepts.
It is fine to put dependencies in parent POM. When you put it there, it means the inherited project is going to have such dependency. There is no right or wrong on this, as long as you know what you are doing (personally I am using different way, will be described later).
However, whether to put shared JARs in EAR and keep skinny WAR, or have a plain EAR with a "full" WAR has nothing to do with your dependency. It is more about the packaging strategy of EAR. Therefore, changing scope of Maven dependency just because you are going to package the project as skinny war, such approach is simply messing up the whole concept of maven dependency. Even more horrible is, when creating your EAR, you need to find out all the dependencies of its included WARs and add it one by one to the EAR POM, that's doubtless not an optimal solution
A pity that current Maven EAR plugin still has no way to declare a skinny war packaging strategy. However there are some workarounds which allow you to do so, without messing around the Maven dependency scope. http://maven.apache.org/plugins/maven-ear-plugin/examples/skinny-wars.html http://maven.apache.org/plugins/maven-war-plugin/examples/skinny-wars.html
(Update: The skinny war receipe seems updated and one of the workaround seems gone. http://docs.codehaus.org/display/MAVENUSER/Solving+the+Skinny+Wars+problem?focusedCommentId=212631587#comment-212631587 This is to include WAR type POM as POM type, so that we do no need to declare the dependencies again in EAR)
3) Use of shared dependencies in parent POM
As I mentioned before, there is no right or wrong to put dependencies in parent. However you should know that, such way actually means all inherited project is going to have such dependency, which is mostly incorrect.
for example, I have a foo-a and foo-b projects under foo, which both inherits foo-parent. Assume foo-a is using spring-core while whole logic of foo-b has nothing to do with it, if you put spring-core as dependency in foo-parent, when you look at foo-b, it is unncessarily having unrelated dependencies spring-core.
The proper way to do is only include dependencies (and other settings) in parent POM that should be shared across all inherited projects. For example, unit testing related dependencies may be a good choice. Dependencies for integration testing may be another example.
However, it doesn't mean we should declare dependencies in each project individually. One of the biggest problem is such approach is going to be hard to maintain same version of dependencies across the whole project.
In order to solve such issue, my recommendation is to make use of dependencyManagement in parent POM, which declares the version (and maybe other settings like scope, excludes). Declaring dependencyManagement is not introducing actual dependencies in inherited POM. It simply declare: "If you declare such dependency, this will be the settings to use". In each inherited POM, simply declare the dependencies' group and artifact (and maybe some project specific settings), so that you can follow the version declared in parent POM.
Maybe a bit hard to understand, here is an example:
foo-parent
<project>
<dependencyManagement> // dependency management doesn't bring actual dependency
<dependencies>
<dependency>
<groupId>org.springframework<groupId>
<artifactId>spring-core<artifactId>
<version>3.1.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.hibernate<groupId>
<artifactId>hibernate-core<artifactId>
<version>3.6</version>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies> // actual shared dependency
<dependency>
<groupId>junit<groupId>
<artifactId>junit<artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
.....
<project>
foo-a
<project>
<dependencies>
<dependency> // note: no version declared
<groupId>org.springframework<groupId>
<artifactId>spring-core<artifactId>
</dependency>
// junit dependency is inherited
<dependencies>
<project>
Ok, first question, i put all the dependencies at paren's pom is this
really correct?
No, your shared dependencies should be put in the ear pom. In the other poms you have to reference the shared dependencies using <scope>provided</scope>.
For example in your ear pom add a dipendency:
<dependency>
<groupId>somegroup</groupId>
<artifactId>someartifact</artifactId>
<version>1.0</version>
</dependency>
In the logica and ui module pom, for example, add these lines:
<dependency>
<groupId>somegroup</groupId>
<artifactId>someartifact</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
In this way the dependency artifact is added only once in the ear package.
and the most interesting part, i don't know hos to compile the grafic
interfade project,(i call ui), it's better create a war or create and
ear with all the necessary (ui+logica+domini+ejb) i 'm a litlle bit
confused about that, i uset o work with projects already estructure
created. I hoper unsderstand my question, i put the rest of pom to
keep an eye. ty.
I don't know if I understand it right. EAR is better suited for project that can have multiple war and/or ejb modules. In your case you can get rid of modularization at all and use a single war package.
finally this is my ear's pom.
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>gpt</artifactId>
<groupId>cat.base.gpt</groupId>
<version>0.0.1</version>
</parent>
<groupId>cat.base.gpt.ear</groupId>
<artifactId>gpt.ear</artifactId>
<name>gpt.ear</name>
<packaging>ear</packaging>
<description>Paquet de l'aplicació J2EE</description>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>gpt.domini</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>gpt.ejb</artifactId>
<version>${project.version}</version>
<type>ejb</type>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>gpt.logica</artifactId>
<version>${project.version}</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>gpt.ui</artifactId>
<version>${project.version}</version>
<type>war</type>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<configuration>
<description>GPT</description>
<displayName>Gestió posicions tributarias</displayName>
<encoding>${project.build.sourceEncoding}</encoding>
<version>1.4</version>
<generateApplicationXml>true</generateApplicationXml>
<modules>
<ejbModule>
<groupId>${project.groupId}</groupId>
<artifactId>${project.parent.artifactId}.ejb</artifactId>
<bundleFileName>${project.parent.artifactId}-ejb.jar</bundleFileName>
</ejbModule>
<jarModule>
<groupId>${project.groupId}</groupId>
<artifactId>gpt.logica</artifactId>
<includeInApplicationXml>true</includeInApplicationXml>
</jarModule>
<webModule>
<groupId>${project.groupId}</groupId>
<artifactId>gpt.ui</artifactId>
<contextRoot>/gpt</contextRoot>
</webModule>
</modules>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<configuration>
<excludeScope>runtime</excludeScope>
</configuration>
</plugin>
</plugins>
</build>
</project>

How to config Flex Mojos Unit test by maven

Like java I would like to perform unit test in maven flex mojo. but unable to perform unit test. Here is the pom file for your observation.
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.formativesoft.flex</groupId>
<artifactId>rdpair</artifactId>
<version>1.0.1</version>
<packaging>swf</packaging>
<name>rdpair Flex</name>
<dependencies>
<dependency>
<groupId>com.adobe.flex.framework</groupId>
<artifactId>flex-framework</artifactId>
<version>4.5.1.21328</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>com.adobe.flexunit</groupId>
<artifactId>flexunit</artifactId>
<version>0.85</version>
<type>swc</type>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<sourceDirectory>src/main/flex</sourceDirectory>
<testSourceDirectory>src/test/flex</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.sonatype.flexmojos</groupId>
<artifactId>flexmojos-maven-plugin</artifactId>
<version>4.0-RC2</version>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
</project>
which properties/plugins/dependency is missing for performing maven unit test?
You should declare which files contains the tests:
<includeTestFiles>
<includeTestFile>*Test.as</includeTestFile>
</includeTestFiles>
And also specify the path to the flash player (move that in your settings.xml)
<properties>
<flex.flashplayer.url>C:\Program Files (x86)\Adobe\Adobe Flash Builder 4.6\player\win\11.1\FlashPlayerDebugger.exe</flex.flashplayer.url>
</properties>

Maven ear problem

I'm finishing my project build (with maven), and it's working great. Now I just have to "pack it", as an ear.
All I need to do is pack 3 dependencies, one .jar and 2 .war. Don't ask me how, that was the way it was done before (with ant), and I'm translating it to maven - next I'll organize the packages, so we can be more productive.
However, I'm having a few problems. First, the package is named null-${version}.ear. It copies itself right to the repository, but in the target folder is wrongly named. And second, it's copying all the other packages dependencies. I want to know what can I do about the null name, and the copying of the packages.
Here is my pom:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>owner</groupId>
<artifactId>coreisp</artifactId>
<version>2.0</version>
</parent>
<groupId>owner</groupId>
<artifactId>coreisp-app</artifactId>
<packaging>ear</packaging>
<version>2.0</version>
<name>Projeto CoreISP</name>
<dependencies>
<dependency>
<groupId>${pom.groupId}</groupId>
<artifactId>coreisp-core</artifactId>
<version>${pom.version}</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>${pom.groupId}</groupId>
<artifactId>coreisp-initializer</artifactId>
<type>war</type>
<version>${pom.version}</version>
</dependency>
<dependency>
<groupId>${pom.groupId}</groupId>
<artifactId>coreisp-site</artifactId>
<type>war</type>
<version>${pom.version}</version>
</dependency>
</dependencies>
<build>
<finalName>${application.id}-${pom.version}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>2.3</version>
<configuration>
<modules>
<jarModule>
<groupId>owner</groupId>
<artifactId>coreisp-core</artifactId>
<includeInApplicationXml>
true
</includeInApplicationXml>
<bundleDir>/</bundleDir>
</jarModule>
<webModule>
<groupId>owner</groupId>
<artifactId>
coreisp-initializer
</artifactId>
<bundleDir>/</bundleDir>
</webModule>
<webModule>
<groupId>owner</groupId>
<artifactId>
coreisp-site
</artifactId>
<bundleDir>/</bundleDir>
</webModule>
</modules>
</configuration>
</plugin>
</plugins>
</build>
</project>
First of all remove the element from your POM, the application.id property is what gives you the "null" name.
As to ensure that transitive dependencies do not end up in your EAR I suggest you specify explicitly in your POM what you do want and what you do not want. In order to keep a dependency out all you need to do is define it in your POM with a scope of provided. I know it's a painful job, but in my opinion it's worth it, to ensure that you get exactly what you want.

Resources