title: How can I use a maven dependency package that has been published to GitLab with Gradle Kotlin?
body: <p>(for reference I am using: IntelliJ as my IDE, Kotlin as the language, and Gradle Kotlin for build)</p>
  <p>The package is successfully published to the GitLab Project's Package Registry, it is listed as a Maven. I can download and access the .pom/.jar/.module file in the GitLab Package Registry, additionally the link to the gitlab repo .pom file (as in the error message below) when clicked will download the .pom for the package (this has me super confused). However when I want to use it as a dependency in a different project it cannot be resolved. I am using an Access Token for authentication of this project. This is the error I am getting when I attempt to build / sync my gradle project:</p>
  <pre><code>Execution failed for task ':compileKotlin'.
  &gt; Error while evaluating property 'filteredArgumentsMap' of task ':compileKotlin'
     &gt; Could not resolve all files for configuration ':compileClasspath'.
        &gt; Could not find &lt;group&gt;:&lt;projectName&gt;:&lt;version&gt;.
          Searched in the following locations:
            -   https://repo.maven.apache.org/maven2/com/example/&lt;projectName&gt;/&lt;version&gt;/&lt;projectName&gt;-&lt;version&gt;.pom
            - https://gitlab.com/api/v4/projects/&lt;packageID&gt;/packages/maven/com/example/&lt;projectName&gt;/&lt;version&gt;/&lt;projectName&gt;-&lt;version&gt;.pom
          Required by:
              project :
  
  Possible solution:
   - Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html
  </code></pre>
  <p>(The group, projectName and version are all filled in with the those things for the project)<br />
  I did read the documentation provided as a possible solution as well as a large number of other sources with potential fixes or ways of setting it up, however I cannot seem to find how to solve or correctly import and use my maven repo. Other sources that I have already checked out / tried to use are:<br />
  <a href="https://www.jetbrains.com/help/space/publish-artifacts-from-a-gradle-project.html#publish-maven-artifacts-using-the-gradle-command-line-tool" rel="nofollow noreferrer">https://www.jetbrains.com/help/space/publish-artifacts-from-a-gradle-project.html#publish-maven-artifacts-using-the-gradle-command-line-tool</a><br />
  <a href="https://gitlab-docs.creationline.com/ee/user/packages/maven_repository/" rel="nofollow noreferrer">https://gitlab-docs.creationline.com/ee/user/packages/maven_repository/</a></p>
  <p>This is what I have in my gradle.build.kts of the package which is attempting to import / use the dependency (again of course packageName, group, version etc are filled in)</p>
  <pre><code>val gitLabAccessToken: String by project
  repositories {
      mavenCentral()
  
      maven {
          url = uri(&quot;https://gitlab.com/api/v4/projects/&lt;projectID&gt;/packages/maven&quot;) 
  
          name = &quot;GitLab&quot;
          credentials(HttpHeaderCredentials::class) {
              name = &quot;Deploy Token&quot;
              value = gitLabAccessToken
          }
          authentication {
              create&lt;HttpHeaderAuthentication&gt;(&quot;header&quot;)
          }
      }
  }
  </code></pre>
  <p>I'm certain I am missing something silly and small, if there is anything more that is needed to get this working so that I can import and use it I will be happy to provide.</p>