pom.xml include scalatest intellij not compiling - maven

I've started a relatively new project, and am trying to follow these instructions (maven) to include scalatest in my intellij project: https://www.scalatest.org/install.
I've successfully done these steps to include maven as part of my project: https://www.jetbrains.com/help/idea/convert-a-regular-project-into-a-maven-project.html#add_maven_support
now I have this:
<?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>independentstudy.project</groupId>
<artifactId>Connect4</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>15</maven.compiler.source>
<maven.compiler.target>15</maven.compiler.target>
</properties>
<dependency>
<groupId>org.scalactic</groupId>
<artifactId>scalactic_2.13</artifactId>
<version>3.2.5</version>
</dependency>
<dependency>
<groupId>org.scalatest</groupId>
<artifactId>scalatest_2.13</artifactId>
<version>3.2.5</version>
<scope>test</scope>
</dependency>
<repositories>
<repository>
<id>artima</id>
<name>Artima Maven Repository</name>
<url>http://repo.artima.com/releases</url>
</repository>
</repositories>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<configuration>
<compilerPlugins>
<compilerPlugin>
<groupId>com.artima.supersafe</groupId>
<artifactId>supersafe_2.13.5</artifactId>
<version>1.1.12</version>
</compilerPlugin>
</compilerPlugins>
</configuration>
<executions>
...
</executions>
</plugin>s
</project>
which is angry about the first set of <dependancy>
What am I missing?

<dependency> tag must be enclosed into <dependencies> tag:
<dependencies>
<dependency>
<groupId>org.scalactic</groupId>
<artifactId>scalactic_2.13</artifactId>
<version>3.2.5</version>
</dependency>
<dependency>
<groupId>org.scalatest</groupId>
<artifactId>scalatest_2.13</artifactId>
<version>3.2.5</version>
<scope>test</scope>
</dependency>
</dependencies>
Refer to Maven documentation for the pom.xml syntax reference: Dependency Management.

Related

Yet another problem with JAXB on JDK-11. Now with tycho-compiler plugin

I decided to migrate our legacy project from jdk7 to jdk11 and can't resolve problem with jaxb.
We have a multi-module maven project.
Here is a part of the parent 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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.XXX.core.build</groupId>
<artifactId>parent</artifactId>
<version>2.1.2</version>
<packaging>pom</packaging>
<name>Core Build</name>
<prerequisites>
<maven>3.6</maven>
</prerequisites>
<modules>
<!-- <module>./targetdefs</module> -->
<module>../com.XXX.core</module>
....more modules
</modules>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jdk-version>11</jdk-version>
<!-- Plugins tycho version -->
<tycho.version>1.7.0</tycho.version>
<javax.activation.version>1.2.0</javax.activation.version>
<jaxb.api.version>2.3.0</jaxb.api.version>
</properties>
<dependencyManagement>
<dependencies>
<!-- API -->
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>2.3.3</version>
<!--<scope>compile</scope>-->
</dependency>
<!--Runtime-->
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.3.3</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<sourceDirectory>${basedir}/src</sourceDirectory>
<testSourceDirectory>${basedir}/src</testSourceDirectory>
<plugins>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-compiler-plugin</artifactId>
<version>${tycho.version}</version>
<configuration>
<source>${jdk-version}</source>
<target>${jdk-version}</target>
</configuration>
</plugin>
</build>
</project>
And here is the child 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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.XXX.core.build</groupId>
<artifactId>parent</artifactId>
<version>2.1.2</version>
<relativePath>../com.XXX.core.build/pom.xml</relativePath>
</parent>
<artifactId>com.XXX.core</artifactId>
<packaging>eclipse-plugin</packaging>
<name>Core</name>
<dependencies>
<!-- API -->
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>2.3.3</version>
<!--<scope>compile</scope>-->
</dependency>
<!--Runtime-->
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.3.3</version>
<scope>runtime</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
</plugin>
</plugins>
<resources>
<resource>
<directory>${basedir}</directory>
<filtering>true</filtering>
<includes>
<include>**/version.properties</include>
</includes>
</resource>
</resources>
</build>
</project>
But after trying to execute mvm clean install on child pom I'm getting
[ERROR] Failed to execute goal org.eclipse.tycho:tycho-compiler-plugin:1.7.0:compile (default-compile) on project com.XXX.core: Compilation failure: Compilation failure:
[ERROR] PATH\core\util\stax\StaxIterator.java:[17]
[ERROR] import javax.xml.bind.JAXBContext;
[ERROR] ^^^^^^^^^^^^^^
[ERROR] The import javax.xml.bind cannot be resolved
Although Netbeans added jakarta.xml.bind-api and jaxb-impl as libraries and there are no any error in file StaxIterator.java
I followed this post How to resolve java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException in Java 9
How could I resolve problem in such situation - I tried all the possibility from StackOverflow :(
The problem was SOLVED
There is no need to add dependencies to maven at all.
The root of the issue (in my case) was in file META-INF/MANIFEST.MF
I've just added javax.xml.bind to the "Import-Package:" section
...
Import-Package: javax.persistence,
javax.xml.bind,
org.apache.commons.beanutils,
org.osgi.framework;version="1.6.0",
org.osgi.service.event;version="1.3.0",
org.slf4j;version="1.7.30"

forcing maven to use local dependency

I'm stuck with a problem which may seem silly, but I don't know how to resolve it. I also looked online, but none of the solutions work for me.
I have a spark code which is using the spark graphX module. I need to make changes inside the graphX and force my project to use this modified version of the graphX. In order to do that, I have first taken out the graphx module from spark source code and compiled it independently. Then I specify the dependency in my application pom.xml file, which has the scope of "system". There is my application 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/maven-v4_0_0.xsd">
<groupId>edu.asu.gears.examples.spark</groupId>
<artifactId>PageRank</artifactId>
<packaging>jar</packaging>
<name>"PageRank"</name>
<version>1.0</version>
<modelVersion>4.0.0</modelVersion>
<!--
<repositories>
<repository>
<id>scala-tools.org</id>
<name>Scala-tools Maven2 Repository</name>
<url>http://scala-tools.org/repo-releases</url>
</repository>
</repositories>
-->
<properties>
<java.version>1.8.0</java.version>
<scala.version>2.11.8</scala.version>
<scala.binary.version>2.11</scala.binary.version>
<scala.tools.version>2.11</scala.tools.version>
<spark.version>2.3.2</spark.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<blaze.version>1.0</blaze.version>
<blaze.base>/home/user/sbiookag/blaze-master</blaze.base>
</properties>
<pluginRepositories>
<pluginRepository>
<id>scala-tools.org</id>
<name>Scala-tools Maven2 Repository</name>
<url>http://scala-tools.org/repo-releases</url>
</pluginRepository>
</pluginRepositories>
<dependencies>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-graphx_${scala.binary.version}</artifactId>
<version>${spark.version}</version>
<scope>system</scope>
<systemPath>${blaze.base}/examples/pageRank/APPs/GraphXFPGAApp/graphx/target/spark-graphx_2.11-3.0.0-SNAPSHOT.jar</systemPath>
</dependency>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>${scala.version}</version>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_${scala.binary.version}</artifactId>
<version>${spark.version}</version>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-mllib_${scala.binary.version}</artifactId>
<version>${spark.version}</version>
</dependency>
<!--
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>blaze_${scala.binary.version}</artifactId>
<version>1.0.1</version>
</dependency>
-->
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.scala-tools</groupId>
<artifactId>maven-scala-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
When I compile my code, it still downloads the graphx dependency and seems like it uses the original jar file during the runtime as well. I really don't know how to resolve this issue. Any help would be appreciated.
spark-mllib contains a dependency on spark-graphx. You should exclude it in your pom.xml :
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-mllib_${scala.binary.version}</artifactId>
<version>${spark.version}</version>
<exclusions>
<exclusion>
<groupId>org.apache.spark</groupId>
<artifactId>spark-graphx_${scala.binary.version}</artifactId>
</exclusion>
</exclusions>
</dependency>

Transitive dependencies are not visible?

I have customModule which is dependant on user-portal app. user-portal is dependent on util module
Here are the relevant POM's
customModule 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/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>parent-build</artifactId>
<groupId>com.myComp.user</groupId>
<version>1</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>customModule</groupId>
<artifactId>dbunit</artifactId>
<dependencies>
<dependency>
<groupId>com.myComp.user</groupId>
<artifactId>user-portal</artifactId>
<version>1.15</version>
<scope>compile</scope>
<type>war</type>
</dependency>
</dependencies>
</project>
user-portal POM having utils as dependency
<dependencies>
<dependency>
<groupId>com.myComp.user.utils</groupId>
<artifactId>utils</artifactId>
<version>1</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
</dependencies>
But utils classes are not visible under customModule. I am not sure why transitive dependencies/classes are not visible here ?
When depending to war packaging, classes inside the war is not visible. You should add <attachClasses>true</attachClasses> to your war plugin in user-portal project. This will produce both war and a jar with the classes.
In the dependent project you should depend to <classifier>classes</classifier> instead of war.
inside user-portal pom.xml
<build>
...
<plugins>
...
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<attachClasses>true</attachClasses>
</configuration>
</plugin>
...
</plugins>
...
</build>
customModule pom.xml
<dependency>
<groupId>com.myComp.user</groupId>
<artifactId>user-portal</artifactId>
<version>1.15</version>
<classifier>classes</classifier>
</dependency>
As a side note, default scope is compile you don't have to specify it.
Source = https://pragmaticintegrator.wordpress.com/2010/10/22/using-a-war-module-as-dependency-in-maven/

SoapUI-PRO with allure reporting - Maven build throws error - Could not find artifact ru.yandex.qatools.allure

I'm using maven build projects to execute Soapui-Pro tests. I am trying to see if Allure can be used to generate reports. But it throws error. Please let me know what seems to be the problem.
Error "Could not find artifact ru.yandex.qatools.allure"
My POM file looks like this:
<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.smartbear.soapuiMavenTutorial</groupId>
<artifactId>SoapUI-Maven-Tutorial</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<name>SoapUI-Maven-Tutorial</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<aspectj.version>1.8.6</aspectj.version>
<allure.version>1.4.14</allure.version>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>ru.yandex.qatools.allure</groupId>
<artifactId>allure-maven-plugin</artifactId>
<version>2.3-SNAPSHOT</version>
</dependency>
</dependencies>
<modules>
<module>PRO-MAY-ER-TestSuite</module>
<module>ErrorCodes-TestSuite</module>
</modules>
<pluginRepositories>
<pluginRepository>
<id>SmartBearPluginRepository</id>
<url>http://www.soapui.org/repository/maven2/</url>
</pluginRepository>
</pluginRepositories>
<build>
<plugins>
<plugin>
<dependencies>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc14</artifactId>
<version>10.2.0</version>
<scope>runtime</scope>
<!--systemPath>C:\maven\ojdbc6.jar</systemPath-->
</dependency>
</dependencies>
<groupId>com.smartbear</groupId>
<artifactId>ready-api-maven-plugin</artifactId>
<version>1.3.0</version>
</plugin>
</plugins>
</build>
</project>
That version of allure-maven-plugin does not exist at Maven central. Pick another version from that list; version 2.2 seems to be the latest.
Alternately, if you need the snapshot version, you will need to specify a repository that has that version; perhaps here.

error during build EAR file in Maven

I'm facing the followinf issue :
Failed to execute goal
org.apache.maven.plugins:maven-ear-plugin:2.7:generate-application-xml
(default-generate-application-xml) on project UserAdminEAR:
Artifact[war:com.syril.administration:UserAdmin] is not a dependency
of the project. -> [Help 1]
what is the solution for this kind of error?
my pom.xml is
<modelVersion>4.0.0</modelVersion>
<groupId>UserAdminEAR</groupId>
<artifactId>UserAdminEAR</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>UserAdmin</name>
<packaging>ear</packaging>
<dependencies>
<dependency>
<groupId>com.syril.dao</groupId>
<artifactId>dataAccess</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.syril.service</groupId>
<artifactId>UserAdminService</artifactId>
<version>0.0.1-SNAPSHOT</version>
<type>war</type>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>2.7</version>
<configuration>
<defaultLibBundleDir>lib</defaultLibBundleDir>
<modules>
<jarModule></jarModule>
<javaModule>
<groupId>com.syril.dao</groupId>
<artifactId>dataAccess</artifactId>
<includeInApplicationXml>true</includeInApplicationXml>
</javaModule>
<webModule>
<groupId>com.syril.service</groupId>
<artifactId>UserAdminSL</artifactId>
<contextRoot>/UserAdminSL</contextRoot>
</webModule>
</modules>
</configuration>
</plugin>
</plugins>
</build>
You will have to add the war as a dependency to the project too, not only in the plugin configuration.
<project ...>
<modelVersion>4.0.0</modelVersion>
<groupId>com.syril.administration</groupId>
<artifactId>UserAdminEAR</artifactId>
<version>YOUR_VERSION_HERE</version>
<packaging>ear</packaging>
<dependencies>
<!-- some other dependencies here -->
...
<!-- Here is the dependency to the war that is referenced in the ear plugin -->
<dependency>
<groupId>com.syril.administration</groupId>
<artifactId>UserAdmin</artifactId>
<version>YOUR_VERSION_HERE</version>
<type>war</type>
</dependency>
</dependencies>
...
</project>
Edit
The <webModule/> artifact is not in your <dependencies/> list. That is what I was suggesting.
Add the following:
<dependency>
<groupId>com.syril.service</groupId>
<artifactId>UserAdminSL</artifactId>
<version>0.0.1-SNAPSHOT</version>
<type>war</type>
</dependency>
OR
Change the <webModule/>:
<webModule>
<groupId>com.syril.service</groupId>
<artifactId>UserAdminService</artifactId>
<contextRoot>/UserAdminSL</contextRoot>
</webModule>
That is of course if UserAdminService is the same as UserAdminSL which I think.

Resources