How to config Flex Mojos Unit test by maven - 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>

Related

Groovy-Eclipse Compilation Failed : Source level should be in '1.1'...'1.8','9'...'15' (or '5.0'..'15.0'): 17

I wanted to compile groovy along with java sources so I added groovy-eclipse-compiler to pom.xml but I got an error:
Groovy-Eclipse: source level should be in '1.1'...'1.8','9'...'15' (or '5.0'..'15.0'): 17
pom.xml as follows:
<?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.app</groupId>
<artifactId>mb2g-alt-jvm</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>17</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy</artifactId>
<classifier>indy</classifier>
<version>3.0.10</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version><!-- 3.6.2 is the minimum -->
<configuration>
<compilerId>groovy-eclipse-compiler</compilerId>
<compilerArguments>
<indy/><!-- optional; supported by batch 2.4.12-04+ -->
<configScript>config.groovy</configScript><!-- optional; supported by batch 2.4.13-02+ -->
</compilerArguments>
<failOnWarning>true</failOnWarning><!-- optional; supported by batch 2.5.8-02+ -->
</configuration>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-compiler</artifactId>
<version>3.7.1</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-batch</artifactId>
<version>3.0.10-02</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
<pluginRepositories>
<pluginRepository>
<id>groovy-plugins-release</id>
<url>https://groovy.jfrog.io/artifactory/plugins-release</url>
</pluginRepository>
</pluginRepositories>
</project>
Intellij Java Compiler Version: Java 17
Module Language Level: Java 17
Error Screenshot :
How can I solve it?
Thank you.
Groovy 3 does not suitably support Java 16+ and so groovy-eclipse-batch is currently capped at Java 15. You can set release (aka java.version in you pom) to 15 as indicated in the error message.
Or you can split Java and Groovy compilation in maven so you can set separate release targets.

Managing Maven plugin versions with Spring Boot BOM

I have a Maven POM for a Spring Boot project. The POM imports the Spring Boot BOM. Now I want to customize the configuration of a Maven plugin, say, mvn-compiler-plugin. I'd like to use the plugin version maven-compiler-plugin.version dictated by the spring-boot-dependencies BOM.
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>ch.ge.mygroup</groupId>
<artifactId>myartifact</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>war</packaging>
<properties>
<spring-boot.version>2.4.2</spring-boot.version>
</properties>
<dependencyManagement>
<dependencies>
<!-- Spring Boot BOM -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring-boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<!-- some particular config here -->
</configuration>
</plugin>
</plugins>
</build>
</project>
But this does work: I come up with a Maven error:
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[ERROR] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin must be a valid version but is '${maven-compiler-plugin.version}'. # line 31, column 26
So I have to explicitly specify the version of the Maven plugin, which I want to avoid.
In summary:
Using
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<!-- some particular config here -->
</configuration>
</plugin>
yields a Maven error.
Using
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<!-- some particular config here -->
</configuration>
</plugin>
works, but prevents me from using the version (3.8.1) dictated by the Spring Boot BOM.
Using
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<!-- some particular config here -->
</configuration>
</plugin>
works, but uses an old version (3.1) of the plugin.
How can I avoid to explicitly specify the plugin version and instead implicitly use the plugin version provided in the Spring Boot BOM?
If you want to override Spring Boot dependencies by simply updating properties, you have to specify the parent POM instead of importing:
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>ch.ge.mygroup</groupId>
<artifactId>myartifact</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>war</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.4.2</version>
<relativePath/>
</parent>
<properties>
<spring-boot.version>2.4.2</spring-boot.version>
<maven-compiler-plugin.version>3.7.0</maven-compiler-plugin.version>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<!-- some particular config here -->
</configuration>
</plugin>
</plugins>
</build>
</project>

How to make Quarkus use local library classes

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:

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.

Resources