I recently hosted a Maven package on Github's package registry and now I am trying to use it. The package is intended to provide the data models that are used by various applications, allowing my team to make changes to the data model package instead of updating the models in all of the Spring applications that share them.
I put the dependency in my pom.xml
file of the application that needs the data model package and then I ran mvn install
(I also had to modify my .m2/settings.xml file to access the repository). I am under the impression that the package was installed because it logs the success and it showed up in my IDE's maven plugin dependency list.
And now I am stuck. Up until now, I assumed that once the package was installed I would be able to import the classes I needed just like I always have with Maven packages. But when I try to do this my IDE can't find the package.
I have started to look at the data model package again, wondering if there is some additional metadata I need to provide. Specifically, I am thinking I might need to provide some module descriptors, but I can't say for sure if this will actually get me any closer to being able to use the package.
Here is the pom.xml
for the data model package.
<?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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.companyname</groupId>
<artifactId>data-model</artifactId>
<version>0.0.2-SNAPSHOT</version>
<name>Data-Model</name>
<properties>
<java.version>11</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<version>2.1.5.RELEASE</version>
</dependency>
</dependencies>
</project>
When I publish the package with Gradle I get this log output:
11:05:23 AM: Executing task 'publishGprPublicationToGitHubPackagesRepository'...
Starting Gradle Daemon...
Gradle Daemon started in 1 s 63 ms
> Task :compileJava UP-TO-DATE
> Task :processResources UP-TO-DATE
> Task :classes UP-TO-DATE
> Task :bootJar UP-TO-DATE
> Task :generateMetadataFileForGprPublication
> Task :generatePomFileForGprPublication
> Task :publishGprPublicationToGitHubPackagesRepository
BUILD SUCCESSFUL in 16s
6 actionable tasks: 3 executed, 3 up-to-date
11:05:39 AM: Task execution finished 'publishGprPublicationToGitHubPackagesRepository'.
The log that prints when I run mvn install
is very long so I won't post it, but it doesn't generate any errors, and I can see that it downloads the datamodel jar and build successfully. It also shows up in the list of external libraries in the project directory.
The group id for the data model is the same as the group id for the application that I want to use it in (my company name). When I type import com.companyname.
it suggests some local packages but doesn't recognize data model. When I hover over the red text the tooltip says Cannot resolve symbol 'datamodel'
What do I need to do now so that my application can import the classes from the maven package I created?