#Converting Maven project to Gradle in IntelliJ
1 messages · Page 1 of 1 (latest)
So did you do the steps I told you?
Yes, download the Gradle and then put it on the C:\Gradle
Should I ran the gradle init inside the project that I want to be converted?
You use Windows tight?
Yes.
did you put create a new environment variable?
I don't know what that is?
In File Explorer right-click on the This PC (or Computer) icon, then click Properties → Advanced System Settings → Environmental Variables.
Under System Variables select Path, then click Edit. Add an entry for C:\Gradle\gradle-7.2\bin. Click OK to save.
Alternatively, you could also add the environment variable GRADLE_HOME and point this to the unzipped distribution. Instead of adding a specific version of Gradle to your Path, you can add %GRADLE_HOME%/bin to your Path. When upgrading to a different version of Gradle, just change the GRADLE_HOME environment variable.
It’s a way to make shortcut names and variables for your system/pc
Okay, I've done the environment variables.
Then if you go into IntelliJ
Open up a new terminal instance
A run gradle -v
Does it say anything?
gradle not recognized
Then you did it incorrectly
Do I need to restart the IntelliJ?
Yeah it says something now.
------------------------------------------------------------
Gradle 7.2
------------------------------------------------------------
Build time: 2021-08-17 09:59:03 UTC
Revision: a773786b58bb28710e3dc96c4d1a7063628952ad
Kotlin: 1.5.21
Groovy: 3.0.8
Ant: Apache Ant(TM) version 1.10.9 compiled on September 27 2020
JVM: 11.0.11 (AdoptOpenJDK 11.0.11+9)
OS: Windows 10 10.0 amd64
aight
Found a Maven build. Generate a Gradle build from this? (default: yes) [yes, no]
Yes
oh god im scared
it wouldn't be fun if there is something goes wrong xd
but i've done it
it says build successful
Oo yeah
yes i have it on github before converting it to gradle
You can delete pom.xml
And restart IntelliJ by invalidating caches also
Just to make sure no issues
Oh ok
No errors on the code or anything
You know the tab where you used to have maven tasks
yeah it's gone now
Does a gradle one exist equivalently?
If not right click the build.gradle and load it
Or if u got some option called load gradle script
how do u load it?
Wait can u send screenshots of ur screen when right clicked build.gradle?
Send a screenie of entire monitor maybe xD
oh okay, my bad xd
pardon my active windows 👀
so yeah, my main goal is to be like SuperiorSkyblock2 source code, i want it to be like that https://github.com/BG-Software-LLC/SuperiorSkyblock2
Hmm yeah
Try removing .idea
And restart and invalidate caches again @pearl pond
Sry for being absent a bit
all good
but yeah remove the .idea folder
and restart again
once u done that
do u get prompted with anything regarding gradle?
ok good
so when u build
you generally want to use the task clean
followed by build
clean and then build?
yup, my libs
Works perfectly tho, no errors.
send ur build.gradle
wait, i don't see any clean on the tasks
it should be under the group build just like the task build
use this instea
so paste it in
and reload gradle project
then instead of running clean then build
run clean then shadowJar instead
got it
Just to let you know that BackpackWrapper is actually the modules/libs that I want to be added to the project.
Right now I have it on different projects because I don't know how to merge it.
oh okay
well
anyways
if u run
clean
then shadowJar
and check the output jar
does it contain what u wantd
what's the path to the output?
build/libs
okay
and yes it has what i want
in fact im gonna test it on the server first
it's running perfectly fine
there are some errors, but it's just from the code
Oh okay
btw
@pearl pond
check out an example of using multi project structure to mess with nms
can't you have the "main" without the modules?
you can
this is the BackpackWrapper code that I have right now https://github.com/aglerr/BackpackWrapper
but then you wont be able to depend on two versions of the same project/dependency simultaneously
create a folder
lets say its named v1_8_r3
then you'd have in settings.gradle
include ':v1_8_r3'
and then in v1_8_r3 you'd have a src folder and a build.gradle file
check out that
if you have any questions then ask 😄
alright, let's see
How can I include an interface from the main code?
nvm, i got it
but, how do u add build tools spigot?
woops nvm, i got it again
it's much more easier on gradle ngl

Conclure, right now I'm struggling with using the modules on the main project.
Oo what’s the struggle?
do i need to do something with the modules on the gradle tasks?
like it's only compiles the main project without all of the modules
Oh
In your main module
Add to the dependencies block
implementation(project(':whatevernamesameasinsettingsgradle'))
@pearl pond
ooh, like shading it into the main project
still it doesn't work, idk why
rootProject.name = 'BackpackCosmetics'
include 'v1_16_R3'
include 'v1_17_R1'
include 'PurpurHook'
Is this on the?
dependencies {
implementation 'me.aglerr.lazylibs.LazyLibs:LazyLibs:1.0'
implementation(project(':PurpurHook'))
implementation(project(':v1_16_R3'))
implementation(project(':v1_17_R1'))
compileOnly 'org.spigotmc:spigot-api:1.17.1-R0.1-SNAPSHOT'
}
kk one sec
Ofc no need to add if it’s public
i trust you to not leak it xd
Yeah won’t
oh, on the unversioned files, i see
Yeah yeah
i've invited you
Dm the project link
Build against Java 8 maybe
Most stuff will still work
Also check DMs
I wrote some stuff there hehe
oh
i already do the interface thingy
i have error while compiling with shadowJar https://paste.md-5.net/anigarugeg.coffeescript it doesn't seem to recognize the modules
On the main project there is interface class named NMSCosmetic and I implement that class on the modules.
That’s the issue
Main has an interface that nms modules depend on,
So nms modules must depend on main
But main is also the final module thus must depend on the nms modules
Cycling dependencies
Move the interfaces to a new module called abstraction or something
Then let main depend on abstraction and any nms module
purpur and nms depend on the abstraction?
Yes
That’s what I meant with the arrow
When working like this you’ll realize how often you might need an interface to segregate but that’s normal
wait, i got confused a little bit xd
so implement the abstraction on nms and purpur
and the main will implement the abstraction?
No
First statement is correct
Main will not implement abstraction, but just depend on it
Cuz in main you’ll have to check what nms version then load the corresponding implementation
And for that you still need the abstraction interfaces on your classpath
how can i access everything inside the abstraction on the main?
after i implement abstraction to nms and purpur, what should i do?
i've moved the interface there too
aglerr
so your lychee-implementation implement nms
and your main implement the lychee-implementation
There’s a difference between implement and depend we first need to discuss
In java the notion of implement means mostly implementing an interface creating a concrete implementation
depend simply means that we are in need of a class/component to make our system work
I think I get that part, it's just because the thing called implementation on the build.gradle
even tho it's under dependencies but idk why i said implement
Yeah the name is somewhat ambiguous
implementation is like compile scoped maven dependency
Yes
Tho maven is actually hiding the actual concepts of how dependencies work
Of course gradle does also but it makes it some what more conspicuous
We have two types of dependencies
Runtime and compile time dependencies
I can explain that later if you’re interested
Let’s get back in topic now
alright
Let’s simplify it actually
so right now i have a abstraction module with a interface class in it
so we have the module abstract
it has the interface TitleSender
.
Then we have one of the nms modules called v1-8-r3
It implements the interface TitleSender so:
TitleSender1_8_R3 implements TitleSender
but in order for v1-8-r3 to implement TitleSender it needs to depend on the module abstract
You understand so far?
yes, i understand it clearly
Okay then we have another module called main not to be confused with the rootproject/parent module
in main we decide what implementation of the interface TitleSender we want to use
But to be able to use TitleSender in main, we also need to add the module abstract as a dependency to the module main right?
uh huh
You cannot have a variable
Bukkit bukkit = new Bukkit(); if we don’t have Bukkit as a dependency right?
The class will be unrecognized
yes
The same story for the module main
In order to be able to use the interface TitleSender from abstract we need to have the module abstract declared as a dependency in the module main
okay i understand
basically you need to depend on the module abstract in order to use the interface TitleSender
Yes
so all of modules and main should depend on the module abstract
Since the interface TitleSender is contained inside the module abstract
In this very case yes
——
So now we have this module tree:
abstract -> main
abstract -> v1-8-r3
right?
Now comes the tricky part
do you need like a module to handle all of the modules?
and on the main you will depend on that module (the one who handle all of the modules)
yes
The main module needs to depend on the abstract module and the nms modules such that it can choose which nms module to use
can you check my files on github?
I added API module which is the abstraction modules, and NMSWrapper module which is the "main" module maybe.
so on the NMSWrapper, I depend the API and NMS modules, and on the main I depend the NMSWrapper module, but I still can't access what's inside the NMSWrapper.
Let me see
I've tried to depend on different modules (on the main build.gradle) but all of the classes from that modules still unrecognized.
kk
i'm heading off, gonna check it tmr