Deploying a Java library with Maven in Github Packages - java

I have been trying to deploy a simple Java library to Github Packages, but regardless the library seems to be deployed/uploaded it is not accessible to projects:
mvn deploy (in the library project)
[INFO] --- maven-deploy-plugin:2.7:deploy (default-deploy) # json-gwt ---
Uploading to github: https://maven.pkg.github.com/mylibrary/json-gwt/com/mylibrary/json-gwt/0/json-gwt-0.jar
Uploaded to github: https://maven.pkg.github.com/mylibrary/json-gwt/com/mylibrary/json-gwt/0/json-gwt-0.jar (11 kB at 2.2 kB/s)
Uploading to github: https://maven.pkg.github.com/mylibrary/json-gwt/com/mylibrary/json-gwt/0/json-gwt-0.pom
Uploaded to github: https://maven.pkg.github.com/mylibrary/json-gwt/com/mylibrary/json-gwt/0/json-gwt-0.pom (6.1 kB at 1.5 kB/s)
Downloading from github: https://maven.pkg.github.com/mylibrary/json-gwt/com/mylibrary/json-gwt/maven-metadata.xml
Downloaded from github: https://maven.pkg.github.com/mylibrary/json-gwt/com/mylibrary/json-gwt/maven-metadata.xml (209 B at 246 B/s)
Uploading to github: https://maven.pkg.github.com/mylibrary/json-gwt/com/mylibrary/json-gwt/maven-metadata.xml
Uploaded to github: https://maven.pkg.github.com/mylibrary/json-gwt/com/mylibrary/json-gwt/maven-metadata.xml (314 B at 192 B/s)
Uploading to github: https://maven.pkg.github.com/mylibrary/json-gwt/com/mylibrary/json-gwt/0/json-gwt-0-sources.jar
Uploaded to github: https://maven.pkg.github.com/mylibrary/json-gwt/com/mylibrary/json-gwt/0/json-gwt-0-sources.jar (7.6 kB at 1.5 kB/s)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 20.943 s
[INFO] Finished at: 2023-02-19T17:08:26+08:00
[INFO] ------------------------------------------------------------------------
Process finished with exit code 0
mvn package on the project (in Github Codespaces) using the library above
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.867 s
[INFO] Finished at: 2023-02-19T09:26:21Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project app-shared: Could not resolve dependencies for project com.myapp:app-shared:jar:0-SNAPSHOT: Failed to collect dependencies at com.mylibrary:json-gwt:jar:0: Failed to read artifact descriptor for com.mylibrary:json-gwt:jar:0: Could not transfer artifact com.mylibrary:json-gwt:pom:0 from/to github (https://maven.pkg.github.com): status code: 401, reason phrase: Unauthorized (401) -> [Help 1
In the Github organization page, it is set that the Members can publish Public packages.
What could be wrong here?

Related

Maven tries download multimodule dependency on `validate` phase

From a build pipeline I want to run validate phase for things like the enforcer plugin. However it does not work for a multimodule project as it tries to download dependencies from repository which are inside the project. However, compile phase does not do that, but for me it is not an option as it is too slow.
pom.xml:
<module>lib</module>
<module>app</module>
lib/pom.xml
<version>1.2.3</version>
app/pom.xml
<dependency>
<artifactId>lib</artifactId>
<version>1.2.3</version>
</dependency>
So, if I do mvn compile it works fine.
But if I do mvn validate it fails validating app module as it tries to download lib-1.2.3 from maven repo. For some reason it now could not see that the lib is a neighbour dependency. Why?
I have created a small repo: https://github.com/kan-izh/so63963768
mvn compile
[INFO] --- maven-enforcer-plugin:3.0.0-M3:enforce (enforce-no-snapshots) # app ---
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) # app ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\Workspace\repo\so63963768\app\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) # app ---
[INFO] No sources to compile
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] parent ............................................ SUCCESS [1.612s]
[INFO] lib ............................................... SUCCESS [1.224s]
[INFO] app ............................................... SUCCESS [0.056s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
mvn validate
[INFO] --- maven-enforcer-plugin:3.0.0-M3:enforce (enforce-no-snapshots) # app ---
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] parent ............................................ SUCCESS [0.979s]
[INFO] lib ............................................... SUCCESS [0.015s]
[INFO] app ............................................... FAILURE [0.020s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.180s
[INFO] Finished at: Wed Sep 23 11:27:38 BST 2020
[INFO] Final Memory: 7M/34M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:3.0.0-M3:enforce (enforce-no-snapshots) on project app: Execution
enforce-no-snapshots of goal org.apache.maven.plugins:maven-enforcer-plugin:3.0.0-M3:enforce failed: org.apache.maven.shared.dependency.graph.
DependencyGraphBuilderException: Could not resolve following dependencies: [com.so.q63963768:lib:jar:1.2.3 (compile)]: Could not resolve depend
encies for project com.so.q63963768:app:jar:1.2.3: Failure to find com.so.q63963768:lib:jar:1.2.3 in http://xxxxxxxxxxxxx.xx.xxxxxxxxxxxxxxxxx.
com:8081/repository/maven-public/ was cached in the local repository, resolution will not be reattempted until the update interval of nexus has
elapsed or updates are forced -> [Help 1]
This is a good question, and it shows a small flaw in how Maven handles dependencies.
You need to know that for every plugin-goal you can define if dependencies should be resolved, and for which scope. (and there's a small difference if having only the poms is enough, or that you also need the artifacts)
compiler:compile requires the dependencies that are required during compile, compiler:testCompile requires the dependencies that are required during test.
For the enforce goal it is tricky: the goal itself doesn't require to have resolved dependencies, nor do most rules( like requireJavaVersion or requireMavenVersion), but some rules do, like the one you try to enforce.
Ideally rules can define if they need to have resolved dependencies, but right now the API doesn't support that.
So you have a couple of solutions: always run with compile, or have an execution-block bound to the compile-pahse if it requires artifacts.

Vaadin no plugin found for prefix jetty

Good evening, im trying to install vaadin framework and integrate it into my eclipse but everytime i try to run the maven build i keep getting this error block, the main part is that the prefix jetty is not recognized and im not sre how to deal with that. Please help
[INFO] Scanning for projects...
[WARNING] The project com.gmail.khaled:my-starter-project:pom:1.0-SNAPSHOT uses prerequisites which is only intended for maven-plugin projects but not for non maven-plugin projects. For such purposes you should use the maven-enforcer-plugin. See https://maven.apache.org/enforcer/enforcer-rules/requireMavenVersion.html
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] My Starter Project [pom]
[INFO] My Starter Project-backend [jar]
[INFO] My Starter Project-ui [war]
[INFO] Downloading from : https://maven.vaadin.com/vaadin-prereleases/org/codehaus/mojo/maven-metadata.xml
[INFO] Downloading from : https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-metadata.xml
[INFO] Downloading from : https://maven.vaadin.com/vaadin-prereleases/org/apache/maven/plugins/maven-metadata.xml
[INFO] Downloading from : https://repo.maven.apache.org/maven2/org/codehaus/mojo/maven-metadata.xml
[INFO] Downloaded from : https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-metadata.xml (14 kB at 13 kB/s)
[INFO] Downloaded from : https://repo.maven.apache.org/maven2/org/codehaus/mojo/maven-metadata.xml (20 kB at 18 kB/s)
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] My Starter Project 1.0-SNAPSHOT .................... SKIPPED
[INFO] My Starter Project-backend ......................... SKIPPED
[INFO] My Starter Project-ui 1.0-SNAPSHOT ................. SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.739 s
[INFO] Finished at: 2019-03-18T21:39:18+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] No plugin found for prefix 'jetty' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (C:\Users\hp\.m2\repository), vaadin-prereleases (https://maven.vaadin.com/vaadin-prereleases), central (https://repo.maven.apache.org/maven2)] -> [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/NoPluginFoundForPrefixException
This error message tells, that there is no maven Jetty plugin defined in the pom.xml where you are trying to run jetty:run target. Hence it is failing. Usually the convention in multi module maven projects is to place Jetty plugin to actual application module. In your case it is probably the "My Starter Project-ui" module. If it is not there you need to add it there.
I had the same problem. When creating a debug configuration in the field goal
do not type: jetty:run
instead type: spring-boot:run

Error on goal package with vaadin-maven-plugin with gitlab CI

I'm using Vaadin and the vaadin-maven-plugin to build a project with front files.
When I am running the goal locally I have no errors and the project builds successfully:
[INFO] Installed Yarn locally.
[INFO] Running 'yarn install' in /home/kaa/Documents/Projects/limitmanager.front/target
[INFO] yarn install v1.6.0
[INFO] [1/4] Resolving packages...
[ERROR] warning babel-preset-env > browserslist#2.11.3: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
[INFO] [2/4] Fetching packages...
[INFO] [3/4] Linking dependencies...
[ERROR] warning "polymer-build > polymer-project-config#3.13.0" has incorrect peer dependency "polymer-analyzer#^3.0.0-pre.17 || ^3.0.0".
[INFO] [4/4] Building fresh packages...
[INFO] success Saved lockfile.
[INFO] Done in 7.12s.
[INFO] Processing frontend files from '/home/kaa/Documents/Projects/limitmanager.front/target/frontend'
[INFO] Running 'gulp build_es6' in /home/kaa/Documents/Projects/limitmanager.front/target
[INFO] [12:28:51] Using gulpfile ~/Documents/Projects/limitmanager.front/target/gulpfile.js
[INFO] [12:28:51] Starting 'build_es6'...
[INFO] Deleting /home/kaa/Documents/Projects/limitmanager.front/target/classes/META-INF/resources/frontend-es6 directory...
[INFO] [12:28:51] Finished 'build_es6' after 5.17 ms
[INFO] Starting to process frontend files.
[INFO] Will minify frontend files.
[INFO] Will bundle frontend files.
[INFO] Will hash bundle file names.
[INFO] Will copy files to target directory '/home/kaa/Documents/Projects/limitmanager.front/target/classes/META-INF/resources/frontend-es6'.
[INFO] Starting operations stated above, this might take a while.
[INFO] Writing bundle manifest to '/home/kaa/Documents/Projects/limitmanager.front/target/classes/META-INF/resources/frontend-es6/vaadin-flow-bundle-manifest.json'
But, running on gitlab CI causes an error:
Caused by: com.github.eirslett.maven.plugins.frontend.lib.ProcessExecutionException: java.io.IOException: Cannot run program "/bcsbankms/limitmanager.front/target/node/node" (in directory "/bcsbankms/limitmanager.front/target"): error=2, No such file or directory
Part of the log:
57389 [ERROR] warning "polymer-build > polymer-project-config#3.13.0" has incorrect peer dependency "polymer-analyzer#^3.0.0-pre.17 || ^3.0.0".
59986 [INFO] [4/4] Building fresh packages...
60052 [INFO] success Saved lockfile.
60055 [INFO] Done in 34.04s.
60071 [INFO] Processing frontend files from '/bcsbankms/limitmanager.front/target/frontend'
60086 [INFO] Running 'gulp build_es6' in /bcsbankms/limitmanager.front/target
60091 [INFO] ------------------------------------------------------------------------
60091 [INFO] BUILD FAILURE
60091 [INFO] ------------------------------------------------------------------------
60093 [INFO] Total time: 59.119 s
60093 [INFO] Finished at: 2018-10-05T05:54:08Z
60094 [INFO] ------------------------------------------------------------------------
60094 [ERROR] Failed to execute goal com.vaadin:vaadin-maven-plugin:11.0.0:package-for-production (default) on project ru.bcs.bank.ms.limitmanager.front: Execution default of goal com.vaadin:vaadin-maven-plugin:11.0.0:package-for-production failed: Transpilation with gulp has failed: 'gulp build_es6' failed. java.io.IOException: Cannot run program "/bcsbankms/limitmanager.front/target/node/node" (in directory "/bcsbankms/limitmanager.front/target"): error=2, No such file or directory -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.vaadin:vaadin-maven-plugin:11.0.0:package-for-production (default) on project ru.bcs.bank.ms.limitmanager.front: Execution default of goal com.vaadin:vaadin-maven-plugin:11.0.0:package-for-production failed: Transpilation with gulp has failed
This is a known issue.
As far as i know, you can ignore it.

401 authorization issue while uploading artifact to nexus from Hudson

First let me point out what exactly is happening.
Am able to do a successful snapshot as well as release build from local workstation.
Artifacts are also successfully uploaded to nexus.
We have a central hudson installation used by many teams/developers.
Snapshot build working successfully from Hudson
Release build for a particular project fails from Hudson with the following error:
[INFO] Uploading: https://nlliprdcn28098.nl.eu.abnamro.com:8443/nexus/content/repositories/SF_DRA-releases/com/abnamro/gsfg/sigt/reports/dra/sf_dra/1.19/sf_dra-1.19.pom
[INFO] [DEBUG] Using Wagon implementation lightweight from default mapping for protocol https
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [ERROR] BUILD ERROR
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] Error deploying artifact: Failed to transfer file: https://nlliprdcn28098.nl.eu.abnamro.com:8443/nexus/content/repositories/SF_DRA-releases/com/abnamro/gsfg/sigt/reports/dra/sf_dra/1.19/sf_dra-1.19.pom. Return code is: 401
[INFO]
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [DEBUG] Trace
[INFO] org.apache.maven.lifecycle.LifecycleExecutionException: Error deploying artifact: Failed to transfer file: https://nlliprdcn28098.nl.eu.abnamro.com:8443/nexus/content/repositories/SF_DRA-releases/com/abnamro/gsfg/sigt/reports/dra/sf_dra/1.19/sf_dra-1.19.pom. Return code is: 401
[INFO] at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:719)
[INFO] at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556)
[INFO] at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:535)
[INFO] at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
[INFO] at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
[INFO] at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
[INFO] at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
Now, the points to note:
Settings file is proper as the same is working from local
User has access to upload to nexus
Same artifact NOT present in nexus
Only difference between local and hudson settings are that in hudson the password are encrypted. But the same encrypted password is working for release job of a diff project but failing for this.
Hudson ver. 1.377 Maven 2.2.1, Nexus : 1.9.2.3
If you can deploy snapshot and releases from your local workstation and the settings.xml for jenkins are similar than check your version 1.19 from your release for the file: sf_dra-1.19.pom, it could be that you allready released from your local workstation and maven can not deploy the same release number more then one time.
So delete the released files from nexus, and remove also tags form your svn or git. then you can release again with the same number.

mvn one:convert don't work?

Finally, I found that some dependency of maven-one-plugin don't install properly. but fix them this plugin work.
question fixed :
I am working on convert a maven 1 project to maven 2 project so I just run this command at the folder of the project:
mvn one:convert
then get a error:
[INFO] Internal error in the plugin manager executing goal
'org.apache.maven.plugins:maven-one-plugin:1.2:convert':
Unable to find the mojo 'org.apache.maven.plugins:maven-one-plugin:1.2:convert' in
the plugin 'org.apache.maven.plugins:maven-one-plugin'
org.apache.maven.model.v3_0_0.PatternSet
Anybody know the reason ? Sorry I just so green on maven and the task is urgent...
Try maven-one-plugin:convert
Please take a look at the plugin manual and check if your configuration matches the required configuration.
http://maven.apache.org/plugins/maven-one-plugin/usage.html
The plugin does exist in central repo
Just wondering if you are running this command using maven 1. If so, can you install maven 2/3 and try?
Edit 1:
Downloaded a sample Maven 1 project from here.
Ran mvn convert:one using the latest maven (maven 3).
Worked successfully
D:\work\sample-echo>mvn one:convert
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-one-plugin:1.2:convert (default-cli) # standalone-pom ---
[INFO] Adding report org.apache.maven.plugins:maven-changes-plugin
[INFO] There are 14 plugin relocators available
[INFO] Writing new pom to: D:\work\sample-echo\pom.xml
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.950s
[INFO] Finished at: Wed Jun 22 15:01:52 IST 2011
[INFO] Final Memory: 4M/15M
[INFO] ------------------------------------------------------------------------

Categories