-
I have created a simple maven archetype project : GitHub - hantsy/maven-archetype-jakartaee9: Maven archetype for Jakarta EE 9 And publish it via Github packages. But read the docs from Github Packages, it requires authentication to install it.
|
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 2 replies
-
Hi @hantsy,
hantsy:
At the moment a token is always required, but it is possible to encode/embed the token in your .pom file. Here is how you would do it:
The
Replace Note, the
hantsy:
There isn’t currently a way to automatically sync with Maven Central. I hope that helps! |
Beta Was this translation helpful? Give feedback.
-
Thanks @jcansdale, it is very helpful. I hope it can be added in the official docs. |
Beta Was this translation helpful? Give feedback.
-
I like this workaround because it shows how anyone can set up their Maven or Gradle projects to get access to packages published to GitHub Packages in public GitHub repository. It should be added to the docs because I came here about to report the issue. I didn’t realize that using a PAT with read packages scope was the recommended way. It would have saved me some time to just have those instructions in the docs (Working with the Apache Maven registry - GitHub Docs). Right now, the docs hint at this by saying:
and
The problem is that as I read this quickstart, not knowing about GitHub Packages in detail, I’m thinking about my previous experience with PATs on GitHub, and I remember that PATs represent my GitHub account, so I’m thinking one would only need a PAT to install a Maven package from a private GitHub repository. I didn’t realize the PATs were also needed for public GitHub repositories. Also, the docs could use some more examples on how to use the packages once they’re published to GitHub Packages. Being somewhat new to Java, I wasn’t familiar with how to configure my
(and then, later, once I got it all working, I’d auth with the PAT more securely than hard coding it in the |
Beta Was this translation helpful? Give feedback.
-
I have another alternative, magik |
Beta Was this translation helpful? Give feedback.
Hi @hantsy,
At the moment a token is always required, but it is possible to encode/embed the token in your .pom file.
Here is how you would do it:
read:packages
scope$ docker run ghcr.io/jcansdale/gpr encode <PAT>
repositories
element you can use in your .pom fileThe
repositories
element will look something like this:Replace
<OWNER>
with your user or org name.Note, the
read…