Execution default of goal com.github.tntim96:jscover-file-maven-plugin:1.0.19:jscover failed: jscoverage_serializeCoverageToJSON is not defined - jscoverage

I am trying to implement JSCover to check the coverage of my code [js files].I have added jscover-file-maven-plugin to the pom.xml of my app. When I try to run maven install on the app, my build is getting failed with following message:
[INFO] --- jscover-file-maven-plugin:1.0.19:jscover (default) # webUi ---
[INFO] Ran JSCover instrumentation
[INFO] BUILD FAILURE
[ERROR] Failed to execute goal com.github.tntim96:jscover-file-maven- plugin:1.0.19:jscover (default) on project webUi: Execution default of goal com.github.tntim96:jscover-file-maven-plugin:1.0.19:jscover failed: jscoverage_serializeCoverageToJSON is not defined"
Can anyone explain what is happening here?enter code here

It doesn't look like any tests were run. If you're not sure of the configuration, you can compare with the working example at https://github.com/tntim96/JSCover-samples. You can also post your configuration and directory structure.
You can try the 1.0.20-SNAPSHOT, which has more logging (but requires Java 8), with the following:
<pluginRepositories>
<pluginRepository>
<id>Sonatype repository</id>
<name>Sonatype's Maven repository</name>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</pluginRepository>
</pluginRepositories>

Related

Failed to execute goal in GitLab CI Pipeline

When I trigger the build pipeline of my application, I get a failed to execute a goal error. However, when I build this application locally, I don't get such exception. When I build via GitLab only I get into this situation.
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-clean-plugin:2.5:clean (default-clean) on project sample-app: Execution default-clean of goal org.apache.maven.plugins:maven-clean-plugin:2.5:clean failed: Plugin org.apache.maven.plugins:maven-clean-plugin:2.5 or one of its dependencies could not be resolved: Failed to collect dependencies at org.apache.maven.plugins:maven-clean-plugin:jar:2.5 -> org.apache.maven:maven-plugin-api:jar:2.0.6: Failed to read artifact descriptor for org.apache.maven:maven-plugin-api:jar:2.0.6: Could not transfer artifact org.apache.maven:maven-plugin-api:pom:2.0.6 from/to central (https://repo.maven.apache.org/maven2): Connection reset -> [Help 1]
For a better look, an image of the error is also attached below...
Along with my team we were investigating the root cause for this issue and we were unable to find a solution. However most frequent reason was that the GitLab-Runner running in a different server has connection issues such that this happens.
One of my team members found a solution and that worked for us. Our issue solved and now the GitLab pipeline builds and runs successfully. That worked for us and hope anyone will the similar issue would also find this helpful.
<pluginRepositories>
<pluginRepository>
<id>central</id>
<name>Central Repository</name>
<url>https://repo.maven.apache.org/maven2</url>
<layout>default</layout>
<snapshots>
<enabled>false</enabled>
</snapshots>
<releases>
<updatePolicy>never</updatePolicy>
</releases>
</pluginRepository>
</pluginRepositories>
<repositories>
<repository>
<id>central</id>
<name>Central Repository</name>
<url>https://repo.maven.apache.org/maven2</url>
<layout>default</layout>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repositories>
Adding the above mentioned code block to POM file solved the issue.
Here you can go for the solution, your pipeline need to be define jdk package add:
Just make sure about the java version as per your project needs:
Java_Build:
stage: build
image:
name: docker:20.10
services:
- docker:dind
before_script:
- apk update
- apk add openjdk8
- apk add maven
script:
- mvn clean install
this will resolve the issue the RCA was about this issue is jdk not available
using apk command you can use the jdk packages in the pipeline to execute.

Can I reach Maven central through Azure DevOps artifacts from a private hosted agent?

I am working from a private network, trying to a buildpipeline for a Maven project. To work with tools on our private network I am trying to use a Private Hosted Agent. Now I know there are some restrictions on reaching Maven Central from our network, normally we use a proxy through Nexus for this.
With the new Maven Upstream feature in Azure artifacts I thought I could use this as a 'proxy'.
Unfortunately the build is failing, it seems to try and reach Maven Central directly (not using my feed) which naturally fails. Below my output and settings
And finally my build output:
2019-10-02T07:27:06.0094285Z Task : Maven
2019-10-02T07:27:06.0094336Z Description : Build, test, and deploy with Apache Maven
2019-10-02T07:27:06.0094403Z Version : 3.158.0
2019-10-02T07:27:06.0094449Z Author : Microsoft Corporation
2019-10-02T07:27:06.0094522Z Help : https://learn.microsoft.com/azure/devops/pipelines/tasks/build/maven
2019-10-02T07:27:06.0094582Z ==============================================================================
2019-10-02T07:27:06.8762822Z [command]C:\windows\system32\reg.exe query "HKLM\SOFTWARE\JavaSoft\Java Development Kit\1.8" /v JavaHome /reg:64
2019-10-02T07:27:06.8762932Z
2019-10-02T07:27:06.8763016Z HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Development Kit\1.8
2019-10-02T07:27:06.8763085Z JavaHome REG_SZ C:\Program Files\Java\jdk1.8.0_221
2019-10-02T07:27:06.8763156Z
2019-10-02T07:27:06.9319606Z [command]C:\windows\system32\cmd.exe /D /S /C "C:\DATA\Choco\lib\maven\apache-maven-3.6.1\bin\mvn.cmd -version"
2019-10-02T07:27:07.4696051Z Apache Maven 3.6.1 (d66c9c0b3152b2e69ee9bac180bb8fcc8e6af555; 2019-04-04T19:00:29Z)
2019-10-02T07:27:07.4700024Z Maven home: C:\DATA\Choco\lib\maven\apache-maven-3.6.1\bin\..
2019-10-02T07:27:07.4709043Z Java version: 1.8.0_221, vendor: Oracle Corporation, runtime: C:\Program Files\Java\jdk1.8.0_221\jre
2019-10-02T07:27:07.4725586Z Default locale: en_US, platform encoding: Cp1252
2019-10-02T07:27:07.4726158Z OS name: "windows server 2016", version: "10.0", arch: "amd64", family: "windows"
2019-10-02T07:27:07.5446027Z SYSTEMVSSCONNECTION exists true
2019-10-02T07:27:07.7710829Z SYSTEMVSSCONNECTION exists true
2019-10-02T07:27:08.0375908Z ##[warning]The settings for the feed or repository already exists in the xml file.
2019-10-02T07:27:08.0492975Z SYSTEMVSSCONNECTION exists true
2019-10-02T07:27:08.0530287Z [command]C:\windows\system32\cmd.exe /D /S /C "C:\DATA\Choco\lib\maven\apache-maven-3.6.1\bin\mvn.cmd -f C:\DATA\Agent\_work\71\s\pom.xml -s C:\DATA\Agent\_work\_temp\settings.xml package"
2019-10-02T07:27:09.9877350Z [INFO] Scanning for projects...
2019-10-02T07:27:10.0851393Z [INFO]
2019-10-02T07:27:10.0897285Z [INFO] ---------< com.ontestautomation.javafortesters:JavaForTesters >---------
2019-10-02T07:27:10.0941394Z [INFO] Building JavaForTesters 1.0-SNAPSHOT
2019-10-02T07:27:10.0942123Z [INFO] --------------------------------[ jar ]---------------------------------
2019-10-02T07:27:10.6741134Z Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-resources-plugin/2.6/maven-resources-plugin-2.6.pom
2019-10-02T07:27:31.8954116Z The process 'C:\DATA\Choco\lib\maven\apache-maven-3.6.1\bin\mvn.cmd' failed with exit code 1
2019-10-02T07:27:31.8954401Z [INFO] ------------------------------------------------------------------------
2019-10-02T07:27:31.8955258Z Could not retrieve code analysis results - Maven run failed.
2019-10-02T07:27:31.8955423Z [INFO] BUILD FAILURE
2019-10-02T07:27:31.8955503Z [INFO] ------------------------------------------------------------------------
2019-10-02T07:27:31.8955591Z [INFO] Total time: 21.842 s
2019-10-02T07:27:31.8955658Z [INFO] Finished at: 2019-10-02T07:27:31Z
2019-10-02T07:27:31.8955759Z [INFO] ------------------------------------------------------------------------
2019-10-02T07:27:31.8955928Z [ERROR] Plugin org.apache.maven.plugins:maven-resources-plugin:2.6 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-resources-plugin:jar:2.6: Could not transfer artifact org.apache.maven.plugins:maven-resources-plugin:pom:2.6 from/to central (https://repo.maven.apache.org/maven2): Connect to repo.maven.apache.org:443 [repo.maven.apache.org/151.101.36.215] failed: Connection timed out: connect -> [Help 1]
2019-10-02T07:27:31.8956093Z [ERROR]
2019-10-02T07:27:31.8958075Z [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
2019-10-02T07:27:31.8958201Z [ERROR] Re-run Maven using the -X switch to enable full debug logging.
2019-10-02T07:27:31.8958274Z [ERROR]
2019-10-02T07:27:31.8958331Z [ERROR] For more information about the errors and possible solutions, please read the following articles:
2019-10-02T07:27:31.8958423Z [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException
2019-10-02T07:27:33.1008909Z No test result files matching C:\DATA\Agent\_work\71\s\**\surefire-reports\TEST-*.xml were found, so publishing JUnit test results is being skipped.
2019-10-02T07:27:33.1015611Z ##[error]Build failed.
2019-10-02T07:27:33.1185161Z ##[section]Finishing: Maven ```
Anyone any ideas?
Thanks!
Can I reach Maven central through Azure DevOps artifacts from a private hosted agent?
The answer should be yes.
The reason why it still reach Maven Central directly is that all pom files inherit from the maven super POM:
http://maven.apache.org/ref/3.0.4/maven-model-builder/super-pom.html
which contains this entry:
<repositories>
<repository>
<id>central</id>
<name>Central Repository</name>
<url>http://repo.maven.apache.org/maven2</url>
<layout>default</layout>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
So, we could overwrite it in your pom with Azure DevOps artifacts:
<repositories>
<repository>
<id>central</id>
<url>https://pkgs.dev.azure.com/xxx/xxx</url>
<releases>
<enabled>false</enabled>
</releases>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>https://pkgs.dev.azure.com/xxx/xxx</url>
<releases><enabled>false</enabled></releases>
</pluginRepository>
</pluginRepositories>
Or you can use the maven Mirrors to to replace a particular repository with your own internal repository.
Check more details about this issue, please check this ticket.
Besides, you could also set the Proxies in the your pom.
Hope this helps.

Why is maven not downloading artifacts from specified repository

I am running Maven 3.5 on Windows 10. Set two repositories in .m2/settings.xml
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>maven-release</name>
<url>https://artifacts.repo.openearth.community/artifactory/distarch-maven-staging</url>
</repository>
<repository>
<snapshots />
<id>snapshots</id>
<name>maven-snapshots</name>
<url>https://artifacts.repo.openearth.community/artifactory/distarch-maven-snapshots</url>
</repository>
</repositories>
Now I need to create a project from a custom quickstart archetype which was published in maven-release repo.
mvn archetype:generate -DarchetypeGroupId=com.lgc.dist -DarchetypeArtifactId=com.lgc.dist.core.msp.quickstart -DarchetypeVersion=0.1 -DinteractiveMode=false -DgroupId=com.foo -DartifactId=com.foo.example.firstservice -Dversion=1.0-SNAPSHOT -DserviceName=FirstService -Dpackage=com.foo.example.firstservice
The quickstart artifact com.lgc.dist.core.msp.quickstart is available at https://artifacts.repo.openearth.community/artifactory/distarch-maven-staging/com/lgc/dist/com.lgc.dist.core.base.pom/0.1/com.lgc.dist.core.base.pom-0.1.pom. Same goes for jar.
However the output of the mvn command shows it is trying to download from apache.org maven repository which was not defined anywhere in settings.xml file
[INFO] Generating project in Batch mode
[WARNING] Archetype not found in any catalog. Falling back to central repository.
[WARNING] Add a repsoitory with id 'archetype' in your settings.xml if archetype's repository is elsewhere.
Downloading: https://repo.maven.apache.org/maven2/com/lgc/dist/com.lgc.dist.core.msp.quickstart/0.1/com.lgc.dist.core.msp.quickstart-0.1.pom
[WARNING] The POM for com.lgc.dist:com.lgc.dist.core.msp.quickstart:jar:0.1 is missing, no dependency information available
Downloading: https://repo.maven.apache.org/maven2/com/lgc/dist/com.lgc.dist.core.msp.quickstart/0.1/com.lgc.dist.core.msp.quickstart-0.1.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.488 s
[INFO] Finished at: 2017-08-03T21:46:38-05:00
[INFO] Final Memory: 15M/170M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:3.0.1:generate (default-cli) on project standalone-pom: The desired archetype does not exist (com.lgc.dist:com.lgc.dist.core.msp.quickstart:0.1) -> [Help 1]
I ran mvn -X to check which settings file it is using and it shows it was .m2/settings.xml. Why is it not working? Is there any special setup for windows 10? The same command works on a Linux VM with the same settings.
For some reason the archetypes weren't found in the repositories or the repositories could not be contacted then it says:
Archetype not found in any catalog. Falling back to central repository.
You can avoid this behaviour if you set your repositories as mirrors.
because of security reasons, in the maven 3.x version, maven-archetype-plugin 3.x is not possible to particular repository from command line argument. you can refer this link http://maven.apache.org/archetype/maven-archetype-plugin/archetype-repository.html. you can use look below version

Deploying CAR to ESB using maven

I am trying to deploy a CAR file to a ESB instance. I am following the instructions here: https://docs.wso2.com/display/DVS370/Deploying+a+CAR+File+with+the+Maven+Plug-In
But when I run the command:
mvn clean deploy -Dmaven.car.deploy.skip=false
I get an error that many other people get.
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Failed to configure plugin parameters for: org.apache.maven.plugins:maven-deploy-plugin:2.4
check that the following section of the pom.xml is present and correct:
<distributionManagement>
<!-- use the following if you're not using a snapshot version. -->
<repository>
<id>repo</id>
<name>Repository Name</name>
<url>scp://host/path/to/repo</url>
</repository>
<!-- use the following if you ARE using a snapshot version. -->
<snapshotRepository>
<id>repo</id>
<name>Repository Name</name>
<url>scp://host/path/to/repo</url>
</snapshotRepository>
</distributionManagement>
Cause: Class 'org.apache.maven.artifact.repository.ArtifactRepository' cannot be instantiated
I don't want to deploy it to a repository, unless I am understanding this wrong.
I created a Maven Multi Module Project to package up the Java Mediator, the ESB Config Project and the Composite Application Project.
Why is this failing?
What is the correct way to deploy a car manually?
To deploy a car file 'manually' you can simply execute a "mvn clean install" and copy the .car file from the target directory and copy to <CARBON_HOME>/repository/deployment/server/carbonapps which hot-deploys the carbon app to ESB server.

Maven: Release:perform fails, but deploy works.

My pom file looks like this :
<distributionManagement>
<repository>
<id>maven-s3-release-repo</id>
<name>S3 Release Repository</name>
<!-- http://bigpetstore.s3.amazonaws.com/maven/ -->
<url>s3://bigpetstore/maven</url>
</repository>
</distributionManagement>
When I run , "mvn deploy", I get my project published to the correct repository.
However, if I run "release:prepare" followed by "release:perform", I get the following error:
[INFO] [ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-
plugin:2.7:deploy (default-deploy) on project BigPetStorePro: Deployment failed:
repository element was not specified in the POM inside distributionManagement element or
in -DaltDeploymentRepository=id::layout::url parameter -> [Help 1]
So, my question is: Why is it that "mvn deploy" is able to easily deploy my contents, however, mvn release:prepare fails to see the contents of the distributionManagement?
Clearly, the tag is present.

Resources