Maven publish, implementation and api

I am trying to publish with the maven publish plugin, however I am encountering some annoying problems.
I have my project setup in the following

   - main
        - core
        - module1
        - module2

And I want to publush both modules, currently I have my gradle set as following:
Main gradle:

allprojects {
    apply plugin: 'java-library'
    apply plugin: 'maven-publish'

    group ''
    version '1.0'

    repositories {

    sourceCompatibility = JavaVersion.VERSION_1_8
    targetCompatibility = JavaVersion.VERSION_1_8

    tasks.withType(JavaCompile) {
        options.encoding = 'UTF-8'


On the core I have just the group id and version.
On module1 :

group ''
version '1.0'

dependencies {
    api project(":core")
    implementation "org.jetbrains:annotations:17.0.0"

java {

publishing {
    publications {
        mavenJava(MavenPublication) {
            artifactId = "project-module1"


    * Credentials

The same thing repeats on module2 , with the only difference is naming the artifact id as project-module2 .
My problem is that when I do gradlew clean publish , both modules get sent to the repository but they don’t implement the api project(":core") , which I need to have in both.
What am I missing here? I also tried adding the shadowJar plugin and doing gradlew clean shadowJar publish but nothing really changed.