getting error when run the JUNIT via gradle - gradle

I am getting the error beloe when using gradle to run Junit.
Could not resolve all dependencies for configuration ':apilink:testCompile'.
> Could not find powermock-module-junit4:version:1.6.0.

You have an invalid dependency declared that cannot be found. The incorrect part is 'powermock-module-junit4:version:1.6.0'. This should instead be 'org.powermock:powermock-module-junit4:1.6.0'.

Related

Unable to deploy to cloudhub mule4 application with Gradle

I am trying to build my mule application and deploy it to cloudhub with Gradle (The Gradle version I'm using is: Gradle 4.10.2) . For this I have added the build.gradle file in my project as shown below:
When I give the Gradle build command it is successful as shown below:
But when I execute Gradle deploy (gradle deploy --info) command, it fails with following error:
Any help to resolve the above issue would be appreciated.
That Gradle has been abandoned for some years and seems to be trying to use a CloudHub REST API endpoint that is no longer valid. If you want to use Gradle you will need a newer Gradle plugin that uses the current CloudHub API. Note that MulesSoft only supports Maven.
You can try running with --stacktrace as the error message suggests to find out more details about the error.

Failed to resolve Gradle Mail dependency

The following error comes every time I try to build my Spring Boot Project (using Gradle 6.5):
Execution failed for task ':compileJava'.
Could not resolve all files for configuration ':compileClasspath'.
Could not resolve org.springframework.boot:spring-boot-starter-mail:2.3.0.RELEASE.
Required by:
project :
Could not resolve org.springframework.boot:spring-boot-starter-mail:2.3.0.RELEASE.
Could not parse POM https://repo.maven.apache.org/maven2/org/springframework/boot/spring-boot-starter-mail/2.3.0.RELEASE/spring-boot-starter-mail-2.3.0.RELEASE.pom
Content is not allowed in prolog.
Could not resolve org.springframework.boot:spring-boot-starter-mail:2.3.0.RELEASE.
Required by:
project : org.springframework.boot:spring-boot-starter-webflux:2.3.0.RELEASE > org.springframework.boot:spring-boot-dependencies:2.3.0.RELEASE
Could not resolve org.springframework.boot:spring-boot-starter-mail:2.3.0.RELEASE.
Could not parse POM https://repo.maven.apache.org/maven2/org/springframework/boot/spring-boot-starter-mail/2.3.0.RELEASE/spring-boot-starter-mail-2.3.0.RELEASE.pom
Content is not allowed in prolog.
I work in a team and nobody else has the same error an it seems like we all have done the same things. I tried manually setting a library to javax.mail.jar that I've downloaded from the Oracle website but it did not help. The following line is from the build.gradle file where the dependency is added:
implementation 'org.springframework.boot:spring-boot-starter-mail'
Can anyone help me with this?

Java 11 with gradle: must specify an absolute path but is ${tools.jar}

We are moving from Java 8 to 11 on a project using jaxb. As it has been removed from the JDK, it has to be included separately, which I have done via gradle config:
compile("javax.xml.bind:jaxb-api:2.2.11")
compile("com.sun.xml.bind:jaxb-core:2.2.11")
compile("com.sun.xml.bind:jaxb-impl:2.2.11")
I am able to run the project, however compileJava gradle job throws errors:
Errors occurred while build effective model from C:\Users\.\.gradle\caches\modules-2\files-2.1\com.sun.xml.bind\jaxb-core\2.2.11\db0f76866c6b1e50084e03ee8cf9ce6b19becdb3\jaxb-core-2.2.11.pom:
'dependencyManagement.dependencies.dependency.systemPath' for com.sun:tools:jar must specify an absolute path but is ${tools.jar} in com.sun.xml.bind:jaxb-core:2.2.11
Errors occurred while build effective model from C:\Users\.\.gradle\caches\modules-2\files-2.1\com.sun.xml.bind\jaxb-impl\2.2.11\2d4b554997fd01d1a2233b1529b22fc9ecc0cf5c\jaxb-impl-2.2.11.pom:
'dependencyManagement.dependencies.dependency.systemPath' for com.sun:tools:jar must specify an absolute path but is ${tools.jar} in com.sun.xml.bind:jaxb-impl:2.2.11
The job finishes and there is a jar created, however when run on production server it stops with this error:
java.lang.NoClassDefFoundError: javax/xml/bind/Unmarshaller$Listener
I'm using Spring Boot v1.5.6 and gradle 4.8.1
The solution is to use a newer version of the jaxb libraries. 2.3.0 is no longer using tools.jar.

Junit failures related to cobertura with multi-module maven project in jenkins

I am getting below test failures when building the multi-module maven project in jenkins.
JDK version - 1.8.51
junit - 4.12
org.codehaus.mojo/cobertura-maven-plugin - 2.7
powermock-easymock-release-full - 1.6.2
net.sourceforge.cobertura / cobertura - 2.1.1
All the above are latest plugins.
Test failures
Error 1
Error Message
net.sourceforge.cobertura.coveragedata.TouchCollector.registerClass(Ljava/lang/String;)V
Stacktrace
java.lang.NoSuchMethodError: net.sourceforge.cobertura.coveragedata.TouchCollector.registerClass(Ljava/lang/String;)V
Error 2
Error Message
Could not initialize class com.test.it.logging.EventLogHandler
Stacktrace
java.lang.NoClassDefFoundError: Could not initialize class com.test.it.logging.EventLogHandler
Error 3
Error Message
Failed to transform class with name com.test.it.ra.ReportArchiveConfProvider. Reason: cannot find net.sourceforge.cobertura.coveragedata.LightClassmapListener
Stacktrace
java.lang.IllegalStateException: Failed to transform class with name com.test.it.ra.ReportArchiveConfProvider. Reason: cannot find net.sourceforge.cobertura.coveragedata.LightClassmapListener
at
org.powermock.core.classloader.MockClassLoader.loadMockClass(MockClassLoader.java:266)
JFYI that it was working fine with JDK 7 and old version plugins. Have anyone faced this issue ? Please help.
I'm not on the same configurations as you, but ran into the same error around LightClassmapListener. I got past the issue by clearing my workspace.
In the jenkins job; click the workspace and select 'Wipe out Current Workspace'

Download latest release from Artifactory with Gradle

Artifactory has a feature of their API where you can download the latest release of a jar file (See http://www.jfrog.com/confluence/display/RTF/Artifactory+REST+API#ArtifactoryRESTAPI-RetrieveLatestArtifact).
Their example is:
GET http://localhost:8080/artifactory/ivy-local/org/acme/[RELEASE]/acme-[RELEASE].jar
I'm working on a project where all builds get published and I want to grab the jar from the last one. So what I'm looking for is a dependency like this in gradle:
compile "org.acme:acme:1.0.0.9.[RELEASE]"
This fails due to escaping of the square brackets so I tried:
compile "org.acme:acme:1.0.0.9.%5BRELEASE%5D"
This seems to allow gradle/ivy to find the file but it fails because the .pom file version does not match what is defined.
FAILURE: Build failed with an exception.
* What went wrong:
Could not resolve all dependencies for configuration ':project:compile'.
> Could not resolve org.acme:acme:1.0.0.9.%5BRELEASE%5D.
Required by:
org.acme:acme:unspecified
> Could not resolve org.acme:acme:1.0.0.9.%5BRELEASE%5D.
> inconsistent module metadata found. Descriptor: CachedResource: /Users/xxxx/.gradle/caches/artifacts-26/filestore/org.acme/acme/1.0.0.9.%5BRELEASE%5D/pom/3986d9c1a27873ce92c0dbd089fc1ca9618f8c1a/acme-1.0.0.9.%5BRELEASE%5D.pom for http://localhost/artifactory/org/acme/acme/1.0.0.9.%5BRELEASE%5D/acme-1.0.0.9.%5BRELEASE%5D.pom Errors: bad version: expected='1.0.0.9.%5BRELEASE%5D' found='1.0.0.9.80'
Is there any way to get gradle and ivy to pull the latest release from artifactory?
I was able to get this working using the ivy syntax:
compile "org.acme:acme:1.0.0.9.+"
This solves the problem I have but I never did manage to get it working using the Artifactory [RELEASE] url.

Resources