I tried to import juniversalcharset package on pom.xml
<dependency>
<groupId>com.googlecode.juniversalchardet</groupId>
<artifactId>juniversalchardet</artifactId>
<version>1.0.3</version>
</dependency>
Here is my bitbucket-pipelines.yml
image: maven:3.3.3
pipelines:
default:
- step:
caches:
- maven
script:
- mvn clean install -Dmaven.wagon.http.ssl.allowall=true -Dmaven.wagon.http.ssl.insecure=true
It downloads and builds correctly on my local machine, but on pipelines it displays the following error:
[ERROR] /opt/atlassian/pipelines/agent/build/src/main/java/package/location/GuessedEncoding.java:[18,15] cannot find symbol
symbol: class UniversalDetector
My guess is that it cannot find the maven artifact when building on pipelines. Is there something wrong with my pipeline configuration?
I found the solution. I forgot to commit and push pom.xml which is why pipelines failed to find the new packages.
Related
How do I create a GitHub workflow that publishes a Maven artifact to GitHub Packages? I'm a bit lost, since I'm using the workflow file provided by GitHub, and Googling the issue doesn't come up with any fixes that apply to my situation.
This what I've gotten so far:
<?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>
[...]
<distributionManagement>
<repository>
<id>github</id>
<name>GitHub Milan Dierick Maven Apache Packages</name>
<url>https://maven.pkg.github.com/MilanDierick/SongsOfSyx</url>
</repository>
</distributionManagement>
[...]
</project>
name: Maven Package
on:
workflow_dispatch:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout#v3
- name: Set up JDK 8
uses: actions/setup-java#v3
with:
java-version: '8'
distribution: 'corretto'
cache: maven
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
settings-path: ${{ github.workspace }} # location for the settings.xml file
- name: Build with Maven
run: mvn package
- name: Publish to GitHub Packages Apache Maven
run: mvn deploy -s $GITHUB_WORKSPACE/settings.xml
env:
GITHUB_TOKEN: ${{ github.token }}
This is the exception I'm getting when running this workflow:
Error: Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project UnofficalSongsOfSyx: Failed to deploy artifacts: Could not transfer artifact github.gsos:UnofficalSongsOfSyx:jar:0.63.45 from/to github (https://maven.pkg.github.com/MilanDierick/SongsOfSyx): transfer failed for https://maven.pkg.github.com/MilanDierick/SongsOfSyx/github/gsos/UnofficalSongsOfSyx/0.63.45/UnofficalSongsOfSyx-0.63.45.jar, status: 422 Unprocessable Entity -> [Help 1]
Error:
Error: To see the full stack trace of the errors, re-run Maven with the -e switch.
Error: Re-run Maven using the -X switch to enable full debug logging.
Error:
Error: For more information about the errors and possible solutions, please read the following articles:
Error: [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
Error: Process completed with exit code 1.
Apparently the artifact ID needs to be all lowercase. Derp.
I'm trying to deploy a multi module project to GitHub packages but whenever Maven hits the "deploy" cycle it fails.
my GitHub action job:
release:
name: Release 🚀
# needs: test
runs-on: ubuntu-latest
permissions:
contents: write
actions: write
repository-projects: write
packages: write
steps:
- uses: actions/checkout#v3
with:
ref: master
- uses: actions/setup-java#v3
with:
java-version: 17
distribution: adopt
cache: maven
- name: Release package
run: |
git config user.name "githubaction[bot]"
git config user.email "actions#github.com"
mvn -B release:prepare
mvn -B release:perform
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
My pom files has the needed config:
<distributionManagement>
<!-- Github distribution -->
<repository>
<id>github</id>
<name>GitHub Packages</name>
<url>https://maven.pkg.github.com/MYUSERNAME/${project.artifactId}</url>
</repository>
</distributionManagement>
<scm>
<developerConnection>scm:git:https://github.com/MYUSERNAME/${project.artifactId}</developerConnection>
</scm>
The prepare step goes fine but a soon as Maven tries to perform the release (and thus hits the deploy stage) I get the error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy (default-deploy) on project my-artifact-sub-module: Failed to deploy artifacts: Could not find artifact my-artifact-sub-module:jar:1.1.0 in github (https://maven.pkg.github.com/mathiasbosman/fs-core) -> [Help 1]
Which is bizar as right before it fails Maven logs:
[INFO] Uploading to github: https://maven.pkg.github.com/my/path/my-artifact-sub-module/1.1.0/my-artifact-sub-module-1.1.0.jar
[INFO] Uploading to github: https://maven.pkg.github.com/my/path/my-artifact-sub-module/1.1.0/my-artifact-sub-module-1.1.0.pom
The structure would be:
my-artifact (pom)
- my-artifact-sub-module (jar)
- my-artifact-sub-module-two (jar)
I tried calling mvn deploy manually in a seperate step but it gives me the same result.
The scm url apperently was wrong (missing the .git extension)
As simple as that.
The complete scm:
<scm>
<connection>scm:git:${project.scm.url}</connection>
<developerConnection>scm:git:${project.scm.url}</developerConnection>
<url>https://github.com/MYUSERNAME/${project.artifactId}.git</url>
<tag>HEAD</tag>
</scm>
I am trying to create a parent/central pom which I plan to use across all my project implementations as a common point for version management of all dependencies.
To make this central dependency pom available to other projects, I want to create a git package so that other projects can import this central dependency pom from git package.
Currently while running github action to publish package, I get the following error.
Error: Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy (default-deploy) on project central-java-dependency: Failed to deploy artifacts: Could not find artifact com.dishant:central-java-dependency:pom:1.0.0 in github (https://maven.pkg.github.com/dishantkamble) -> [Help 1]
Error:
Error: To see the full stack trace of the errors, re-run Maven with the -e switch.
Error: Re-run Maven using the -X switch to enable full debug logging.
Error:
Error: For more information about the errors and possible solutions, please read the following articles:
Error: [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
Error: Process completed with exit code 1.
Below is my action yml
name: Java CI with Maven
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- name: Set up JDK 11
uses: actions/setup-java#v1
with:
java-version: 11
- name: Build with Maven
run: mvn -B package --file pom.xml
- name: Publish to GitHub Packages Apache Maven
run: mvn deploy
env:
GITHUB_TOKEN: ${{ github.token }}
My pom contains distributionManagement as follows
<distributionManagement>
<repository>
<id>github</id>
<name>GitHub Dishant Apache Maven Packages</name>
<url>https://maven.pkg.github.com/dishantkamble</url>
</repository>
</distributionManagement>
Can someone help to get this central dependency pom deployed to github packages so that my other projects can successfully import this pom as parent dependency.
I was able to fix this with the following two changes.
maven.yml
name: Java CI with Maven
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- name: Set up JDK 11
uses: actions/setup-java#v1
with:
java-version: 11
- name: Build with Maven
run: mvn -B package --file pom.xml install
- name: Publish to GitHub Packages Apache Maven
run: mvn deploy -s $GITHUB_WORKSPACE/settings.xml -DskipTests
env:
GITHUB_TOKEN: ${{ github.token }}
pom.xml
update existing distribution management with the repository name
<distributionManagement>
<repository>
<id>github</id>
<name>GitHub Dishant Apache Maven Packages</name>
<url>https://maven.pkg.github.com/dishantkamble/central-java-dependency</url>
</repository>
</distributionManagement>
I will try to keep the description brief. We have a couple of projects. Some of them are full blown Spring Boot apps, some of them are Maven Dependency projects (used in those Spring Boot apps).
I have set up a Jenkins server for automating pipelines. Jenkins calls Google Cloud Build to build projects/docker images and cache dependencies. It also calls SonarQube in a step. This all works fine for the Spring Boot apps, but the SonarQube step fails for the dependency projects. The error is Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.7.0.1746:sonar (default-cli) on project projectname: Not inside a Git work tree: / -> [Help 1].
The Dockerfile for the project:
FROM maven:3.5-jdk-8-alpine
# Copy local code to the container image.
COPY pom.xml settings.xml ./
RUN mvn -s settings.xml dependency:go-offline
COPY src ./src
# Build a release artifact.
RUN mvn verify -DskipTests -s settings.xml
The cloudbuild.yaml:
substitutions:
_IMAGE_NAME: "projectname"
steps:
- name: "docker"
entrypoint: "sh"
args:
- "-c"
- |-
docker pull gcr.io/gcp-project/${_IMAGE_NAME}:$_TAG
docker pull gcr.io/gcp-project/${_IMAGE_NAME}:latest || true
- name: "docker"
args:
- "build"
- "-t"
- "gcr.io/gcp-project/${_IMAGE_NAME}"
- "-t"
- "gcr.io/gcp-project/${_IMAGE_NAME}:$_TAG"
- "--cache-from"
- "gcr.io/gcp-project/${_IMAGE_NAME}:latest"
- "--cache-from"
- "gcr.io/gcp-project/${_IMAGE_NAME}:$_TAG"
- "."
- name: "gcr.io/gcp-project/${_IMAGE_NAME}"
entrypoint: "bash"
args:
- "-ce"
- |-
mvn -f /pom.xml -s ./settings.xml sonar:sonar -Dsonar.host.url=https://sonar.server.com -Dsonar.login=${_SONAR_KEY}
- name: "gcr.io/gcp-project/${_IMAGE_NAME}"
args:
- "mvn"
- "deploy"
- "-s"
- "/settings.xml"
images: ["gcr.io/gcp-project/${_IMAGE_NAME}"]
There are two very confusing things. If i run the maven command locally, the analysis completes successfully. Also, if i run the local Google Cloud Build tool (cloud-build-local) it also passes.
I have verified that the .git folder is not uploaded. It is neither with the Spring Boot apps.
I copied the settings.xml from the Jenkins server locally and used that one. Neither the Spring Boot apps or the dependencies define a sonar-project.properties.
Is there anyone who can shed some light on this?
Thanks in advance!
EDIT
I created 2 repositories that are able to replicate this problem:
Non-working: https://github.com/claystation/mvnsonarapp
Working: https://github.com/claystation/mvnsonarappworking
I think the main difference is the dependency project not having #SpringBootApplication?
Ok, so i finally figured it out how to solve this, by doing the MCVE.. Unfortunately not WHY the problem exists.
The main difference between the projects was the #SpringBootApplication annotation. I thought this might have something to do with having the spring-boot-starter-parent parent defined.
I removed the parent part and now my project is passing in Sonar. If there is ever someone who can explain WHY Sonar gives this error with the parent defined but no #SpringBootApplication annotation, that would be very helpful.
Thanks!
I created a maven project in batch mode by typing the following command:
mvn archetype:generate -B -DarchetypeGroupId=com.adobe.granite.archetypes -DarchetypeArtifactId=aem-project-archetype -DarchetypeVersion=22 -DgroupId=com.adobe.aem.guides -Dversion=0.0.1-SNAPSHOT -DappsFolderName=wknd -DartifactId=aem-guides-wknd -Dpackage=com.adobe.aem.guides.wknd -DartifactName="WKND Sites Project" -DcomponentGroupName=WKND -DconfFolderName=wknd -DcontentFolderName=wknd -DcssId=wknd -DisSingleCountryWebsite=n -Dlanguage_country=en_us -DoptionAemVersion=6.5.0 -DoptionDispatcherConfig=none -DoptionIncludeErrorHandler=n -DoptionIncludeExaples=y -DoptionIncludeFrontendModule=y -DpackageGroup=wknd -DsiteName="WKND Site"
when I type mvn -PautoInstallSinglePackage clean install
I get the following error:
[ERROR] Failed to execute goal on project aem-guides-wknd.ui.apps: Could not resolve dependencies for project com.adobe.aem.guides:aem-guides-wknd.ui.apps:content-package:0.0.1-SNAPSHOT: Could not find artifact com.adobe.aem.guides:aem-guides-wknd.ui.frontend:zip:0.0.1-SNAPSHOT
From the error I guess and when I searched that there is no such artifactid in maven repository. Can someone please help me out here?
If your sole requirement is to build the wknd project, then just download the maven project from git and import it as a maven project in eclipse. After that build it. That should hopefully resolve your issue.
You have below options :
1.You Can check your root pom.xml file. There you can comment out ui.frontend module i.e. <!--module> ui.frontend </module-->. After hat you can run your package build command.
2. you can got to each sub-module like core,ui.appss and run following command to build individually mvn clean install -PautoInstallBundle
Let me know if this helps or will look into some other solution.
Inside parent pom.xml comment dispatcher module
example :
<modules>
<module>all</module>
<module>core</module>
<module>ui.frontend</module>
<module>ui.apps</module>
<module>ui.apps.structure</module>
<module>ui.config</module>
<module>ui.content</module>
<module>ui.content.sample</module>
<module>it.tests</module>
**<!--<module>dispatcher</module>-->**
<module>ui.tests</module>
</modules>