├── .gitignore
├── README.md
├── pom.xml
└── src
└── main
└── java
└── de
└── tfr
└── test
└── UseLibTest.java
/.gitignore:
--------------------------------------------------------------------------------
1 | # IntelliJ project files
2 | .idea
3 | *.iml
4 | target
5 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # GitHub Package Registry + Maven Example
2 |
3 | This project shows how add a maven dependency stored in the brand new [GitHub Package Registry](https://github.com/features/package-registry).
4 | For now this feature is in beta. To use it, you have to [sign up for the beta](https://github.com/features/package-registry/signup).
5 |
6 | The package is released [here](https://github.com/TobseF/HelloMaven/packages).
7 |
8 | To deploy a package by your own and setup a [GitHub Actions](https://github.com/features/actions) CI, check the [HalloMaven](https://github.com/TobseF/HelloMaven/) project.
9 |
10 | You can find more info for Package Registry in the official GitHub doc:
11 | 📚 [Configuring Apache Maven for use with GitHub Package Registry](https://help.github.com/en/articles/configuring-apache-maven-for-use-with-github-package-registry)
12 |
13 | ## Add dependency
14 | The dependency is added like every other in maven in the `pom.xml`:
15 |
16 | ```xml
17 |
18 | github.tobsef
19 | hello-maven
20 | 1.2.1
21 |
22 | ```
23 | To point maven to the repo, we also have to specify the `repositoriy` in the `pom.xml`.
24 | ```xml
25 |
26 |
27 | github
28 | GitHub TobseF Apache Maven Packages
29 | https://maven.pkg.github.com/TobseF/HelloMaven
30 | true
31 | true
32 |
33 |
34 | ```
35 | ## Enable authentication
36 | The registry access is available through the GitHub api which is protected by an authorisation.
37 | So you have ro add the credentials to the Package Registry to your global `settings.xml`:
38 | `USER_HOME\.m2\settings.xml`
39 |
40 | ``` xml
41 |
42 |
43 | github
44 | YOUR_USERNAME
45 | YOUR_AUTH_TOKEN
46 |
47 |
48 | ```
49 | Replace the `YOUR_USERNAME` with your GitHub login name.
50 | Replace the `YOUR_AUTH_TOKEN` with a generated GitHub personal access token:
51 | _GitHub_ > _Settings_ > _Developer Settings_ > _Personal access tokens_ > _Generate new token_:
52 | The token needs at least the `read:packages` scope.
53 | Otherwise you will get a `Not authorized` exception.
54 |
55 |
56 | ### Setup your own
57 | If you want to use the Package Registry in your own project, make sure its activated.
58 | Therefore check your project package site:
59 | https://github.com/YOUR_NAME/YOUR_PROJECT/packages
60 |
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | de.tfr.test
8 | maven-repo-test
9 | 1.0-SNAPSHOT
10 |
11 |
12 |
13 | github
14 | GitHub TobseF Apache Maven Packages
15 | https://maven.pkg.github.com/TobseF/HelloMaven
16 |
17 | true
18 |
19 |
20 | true
21 |
22 |
23 |
24 |
25 |
26 |
27 | github.tobsef
28 | hello-maven
29 | 1.2.3
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/src/main/java/de/tfr/test/UseLibTest.java:
--------------------------------------------------------------------------------
1 | package de.tfr.test;
2 |
3 | import github.tobsef.demo.HelloMaven;
4 |
5 | public class UseLibTest {
6 |
7 | public static void main(String[] args) {
8 | HelloMaven.run();
9 | }
10 |
11 | }
12 |
--------------------------------------------------------------------------------