#Maven Publish build.gradle, I need some help.

1 messages ยท Page 1 of 1 (latest)

leaden copper
#

I need help with publishing my gradle project to my maven public repo with the maven-publish plugin?

glass wasp
#

just use maven lol

leaden copper
#

Is there a way that I can switch my project from gradle to maven?

honest spindle
#

dont

leaden copper
#

Don't?

honest spindle
#

some prefer gradle, some prefer maven

#

its not difficult with gradle either

leaden copper
#

What is better ?

#

Gradle seems to be working 10x time faster for me.

honest spindle
#

idk im stupid

leaden copper
#

Well what do you use ๐Ÿ˜‚

honest spindle
#

gradle :)

leaden copper
#

Oh, do you know how to do it then ?

honest spindle
#

never published to public tho

leaden copper
#

Welll I need to do it locally.

honest spindle
leaden copper
#

Not public sorry.

hazy elbow
#

use whatever build system you feel most comfortable using

#

if you just want it local you can just run the publishToMavenLocal with adding a publishing config

#

groovy or kotlin dsl?

honest spindle
#

publishing {
publications {
maven(MavenPublication) {
from components.java

        artifactId = "tottoriutils"
    }
}

}

my publishing task for gradle 8.8 for reference

leaden copper
#

Idk what that is ๐Ÿ˜‚

hazy elbow
#

there is task for it

honest spindle
#

oh true

hazy elbow
leaden copper
#

Oh I use build.gradle.

hazy elbow
#

add ```

publishing {
publications {
maven(MavenPublication) {
from components.java
}
}
}

#

then just run the publishToMavenLocal task and its on your maven local, to use it make sure you have mavenLocal() in the repositories

honest spindle
#

for me the casing was wrong tho

ebon imp
#
Reposilite

Lightweight and easy-to-use repository manager for Maven based artifacts in JVM ecosystem. This is simple, extensible and scalable self-hosted solution to replace managers like Nexus, Archiva or Artifactory, with reduced resources consumption.

leaden copper
#

oh okay

#

well i'm having the following issue

#
Build file 'C:\Users\andre\Desktop\MC-Plugins\Library\build.gradle' line: 8

A problem occurred evaluating root project 'Library'.
> Could not find method publishing() for arguments [build_b2ltjvj9w4m8zjs6sl3xxs8xr$_run_closure1@5e807a9a] on root project 'Library' of type org.gradle.api.Project.

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.

leaden copper
hazy elbow
#

the the build.gradle, it should be its own declaration

leaden copper
#
plugins {
    id 'java'
}

group = 'com.ancho.library'
version = '1.0'

repositories {
    mavenCentral()
    maven {
        url = 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/'
        
        content {
            includeGroup 'org.bukkit'
            includeGroup 'org.spigotmc'
        }
    }

    maven { url = 'https://oss.sonatype.org/content/repositories/snapshots' }
    maven { url = 'https://oss.sonatype.org/content/repositories/central' }
}

dependencies {
    testImplementation platform('org.junit:junit-bom:5.10.0')
    testImplementation 'org.junit.jupiter:junit-jupiter'

    implementation 'org.apache.commons:commons-lang3:3.12.0'

    compileOnly 'org.spigotmc:spigot-api:1.20.2-R0.1-SNAPSHOT'
    compileOnly 'org.spigotmc:spigot:1.20.2-R0.1-SNAPSHOT'
}

publishing {
    publications {
        maven(MavenPublication) {
            from components.java
        }
    }
}

test {
    useJUnitPlatform()
}```
ebon imp
#

You need to add the maven-publish plugin

leaden copper
#

This is my build.gradle.

#

oh

ebon imp
#

id 'maven-publish' I believe

leaden copper
#

yeap

#
'maven' cannot be applied to '(java.lang.Class<org.gradle.api.publish.maven.MavenPublication>, groovy.lang.Closure<org.gradle.api.publish.Publication>)'

Cannot infer argument types
ebon imp
#

Also if you're depending on the spigot server, no need to depend on the API nor depend on apache commons lang

leaden copper
#

these are just warnings, but they're not gonna cause any issues, right?

ebon imp
#

It's create(MavenPublication)

leaden copper
#
publishing {
    publications {
        create(MavenPublication) {
            from components.java

            groupId = 'com.ancho.library'
            artifactId = 'AnchoLibrary'
            version = '1.0'
        }
    }
}``` This is the correct one, right?
ebon imp
#

Yea

#

You're also gonna have to add a repo to publish to

leaden copper
#

Well I wanna publish it locally.

ebon imp
#

Oh yeah then that's enough

leaden copper
#

so mavenLocal()?

ebon imp
#

the publishToMavenLocal task exists, you don't need to add a repo

leaden copper
#

then just

#

implementation 'com.ancho.library:AnchoLibrary:1.0'

#

right?

ebon imp
#

Yeah, make sure to add your local maven repo

leaden copper
#

with mavenLocal()

ebon imp
#

Yeap

leaden copper
#

yeah mavenLocal() should be good into the repositories, right?

ebon imp
#

Yes

leaden copper
#

Perfect, thank you so much mate!