Apache Beam java Testing ExpectedLogs Maven - java

I'm using apache beam with Maven and in the pom.xml the dependency is
<dependency>
<groupId>org.apache.beam</groupId>
<artifactId>beam-sdks-java-core</artifactId>
<version>2.8.0</version>
</dependency>
I can use
import org.apache.beam.sdk.testing.PAssert;
but i can not use
import org.apache.beam.sdk.testing.ExpectedLogs;
like here https://github.com/apache/beam/blob/master/runners/google-cloud-dataflow-java/src/test/java/org/apache/beam/runners/dataflow/DataflowRunnerTest.java
Any help will be appreciated!

It is because org.apache.beam.sdk.testing.PAssert is in beam-sdks-java-core but org.apache.beam.sdk.testing.ExpectedLogs is in beam-sdks-java-core-test.
I don't think org.apache.beam.sdk.testing.ExpectedLogs is published into Beam maven artifacts. You can compile the module locally from https://github.com/apache/beam and add it to your maven project.
To compile beam-sdks-java-core-test locally, you first can cd to parent directory of Beam. Then run command ./gradlew :beam-sdks-java-core:shadowTestJar. After that you should be able to find a jar named beam-sdks-java-core-2.10.0-SNAPSHOT-tests.jar in sdks/java/core/build/libs.

Related

How to merge gradle with maven

I imported a gradle project on my eclipse. (I am using Java 11.) I had codes which uses jakarta.xml libraries.
import jakarta.xml.soap.*;
For it to function, I added Maven dependencies for jaxws-rt:
<dependencies>
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-ri</artifactId>
<version>3.0.0-M3</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>jakarta.xml.ws</groupId>
<artifactId>jakarta.xml.ws-api</artifactId>
<version>2.3.3</version>
</dependency>
</dependencies>
But when I try to generate the build, it shows following error:
error: package jakarta.xml.soap does not exist
import jakarta.xml.soap.*;
If I refresh the project as a Maven project the gradle feature gets disabled. If I run it as a gradle project, the maven dependencies get disabled. Can you please suggest how to run the build?
Do not manage separate dependencies on two different build platforms.
You will want to choose either Maven or Gradle. Having two build systems will cause unnecessary duplicate work and still requires continued maintenance. Going down this path will require you to manage two separate build files that are identical in nature. Every dependency in your gradle config will also need to be added to your maven config.
Instead of trying to create a pom.xml for the Maven build, you will want to determine the Gradle equivalent for the libraries you want to pull.
compile group: 'com.sun.xml.ws', name: 'jaxws-ri', version: '3.0.0-M3', ext: 'pom'
compile group: 'jakarta.xml.ws', name: 'jakarta.xml.ws-api', version: '2.3.3'

The import com.fasterxml.jackson cannot be resolved error on trying to setup a legacy Java Spring boot application

Following import in an existing class is throwing a compilation error "import cannot be resolved" on eclipse -
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
The corresponding jar inclusion in pom.xml is -
<properties>
<fasterxml.version>0.7.0</fasterxml.version>
</properties>
<dependency>
<groupId>com.fasterxml</groupId>
<artifactId>jackson-module-hibernate</artifactId>
<version>${fasterxml.version} </version>
</dependency>
I checked that the corresponding jar file is not present in .m2.
There is no such directory as jackson-module-hibernate inside .m2/fasterxml/
However, jar corresponding to another declaration is present in .m2 -
com.fasterxml.jackson.core
jackson-annotations
2.6.1
Is present in .m2/fasterxml/jackson/core/jackson-annotations/2.6.1
as jackson-annotations-2.6.1.jar
Setup details
Maven version - 3.3
Java version - 1.8.
Eclipse latest version - 2019-06.
I could not verify the absence of the first jar in the working sandbox setup, but that's how it should be, as we had taken a backup of the .m2 directory. How is it possible that the application runs in another setup without the presence of the jar.
Note - I am still a struggler when it comes to maven dependencies and the setup of this legacy project has made me pull hairs. I am trying to do the setup on eclipse. It got setup sometime back, after a lot of struggle, but before I could document all the steps/workarounds we made, I deleted the working setup by mistake.
Update
The pom declaration for jackson-annotations is in the pom of another project. That project has been included in the pom of the dependent project as -
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.dependencies</groupId>
<artifactId>dependency-project</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
You also need:
Execute mvn clean compile from Command Line, on another project
Execute mvn clean compile on your project
Right-click on Project > Maven > Update project...

Cucumber without Maven

We are not Maven yet, and I’m trying to run a cucumber feature. Getting the below error.
java.lang.NoClassDefFoundError: org.picocontainer.PicoBuilder at
cucumber.runtime.java.picocontainer.PicoFactory.start(PicoFactory.java:17)
Below is my folder structure for src.
src
test.java.stepdefinition.holiday
Myholiday_StepDef.java
MyRunner.java
test.resources.features
holiday.feature
Add Jar file of “PicoContainer Core” to build path of your project if you are using java project.
You can use maven dependency for “PicoContainer Core” to your pom.xml (for Maven project) as mentioned below.
<dependency>
<groupId>org.picocontainer</groupId>
<artifactId>picocontainer</artifactId>
<version>2.14.1</version>
</dependency>

Import / Dependency Cannot be Resolved in Maven

I'm using a program that relies on the following two imports:
import org.lwjgl.opencl.CLDevice;
import org.lwjgl.opencl.CLPlatform;
Eclipse is reporting that the "import cannot be resolved" even though I've added LWJGL OpenCL as a dependency to my project.
Here's a snapshot of my POM file:
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-opencl</artifactId>
<version>3.1.6</version>
</dependency>
I've read somewhere that these classes only exist in an earlier version so I tried changing the version to all of the versions found here ( from 3.1.0 to 3.1.6) but none of them resolved the issue.
Is there an earlier/different version that is not on the Maven repository page? If not where could I find the said class?
Thanks
It seems that you are using the abandoned lwjgl v2 library. It can be found in another Maven repository:
<dependency>
<groupId>org.lwjgl.lwjgl</groupId>
<artifactId>lwjgl</artifactId>
<version>2.9.3</version>
</dependency>

customized job in maven

I generated jars from Talend,and I suppose to use them in a maven project.After some research I know that I have to install this jars in the local maven repository using:
mvn install:install-file -Dfile=non-maven-proj.jar -DgroupId=some.group -DartifactId=non-maven-proj -Dversion=1 -Dpackaging=jar
and then add a dependency:
<dependency>
<groupId>....</groupId>
<artifactId>...</artifactId>
<version>...</version>
</dependency>
But I don't know what to put exactly in the groupId,artifactId and version tag. Help plz
Go to the maven repository https://mvnrepository.com and search for your dependency. Click on the version number and it will show you the complete dependency tag for your talend. e.g
<!-- https://mvnrepository.com/artifact/org.talend.esb.job/org.talend.esb.job.api -->
<dependency>
<groupId>org.talend.esb.job</groupId>
<artifactId>org.talend.esb.job.api</artifactId>
<version>6.3.1</version>
You should specify what is this "Talend"?
Here is simple introduction to maven pom structure:maven pom doc
groupId: This is generally unique amongst an organization or a project.
artifactId: The artifactId is generally the name that the project is known by.
version: is last piece of specification which package to use.
You can find specification to mvn dependencies on maven repository page. Here is an example for Talend ESB jar (newest version):
<!-- https://mvnrepository.com/artifact/org.talend.esb.job/org.talend.esb.job.api -->
<dependency>
<groupId>org.talend.esb.job</groupId>
<artifactId>org.talend.esb.job.api</artifactId>
<version>6.3.1</version>
</dependency>
BTW if you are just using it locally , then you can install jar with any group Id,artifact Id and version you feel like. Just make sure you use the same in your dependencies in project POM.
However this is not the recommended approach, but if you are not sure about the maven coordinates( group Id, artifact Id and version) you can use above given hack.

Categories

Resources