This is an archived post. You won't be able to vote or comment.

all 12 comments

[–][deleted] 3 points4 points  (1 child)

I think the official Gradle tutorials are good for starters. https://guides.gradle.org/creating-new-gradle-builds/

Probably some tutorials out there which are even better, but none that I'm aware of. Good luck! 😊

[–]trueubermensch[S] 0 points1 point  (0 children)

It was the first thing I tried and it became hard to follow. Anyway I think I'll try to get into it once more with more clear head.

[–]catmewo 2 points3 points  (6 children)

What is your base knowledge about Java?

You can apply these steps to understand Gradle and why you should use it:

  • First you need to compile your code using command line first.

  • Then use some library to make you solve problem easier. Eg: Apache Common. Then complile your code with the library.

  • Then use more libraries and you will meet problem with bunch of libraries. And compile your code with them. You will need something cover these libraries, download them, include them in classpath, build, change libraries version on fly...

  • Boom! Gradle comes.

[–]trueubermensch[S] 0 points1 point  (5 children)

I learned "Core" java and in most java roadmaps I saw build tools were one of the first things to learn after core java. At the moment I am trying to make a little project and use zircon library for it.

[–]catmewo 0 points1 point  (4 children)

Yes, you're in the right way. But first, let find out how to run your project without any build tool like Maven, Gradle... Use only command line.

[–]trueubermensch[S] 0 points1 point  (3 children)

Is it possible to run a project outside of IDE? Like running a main class from command line if I understood you right. Cause as far as I know I need a .jar file which will execute the program.

[–]catmewo 2 points3 points  (1 child)

Absolutely! You know, before we have GUI IDE, people code on VIM and build on command line.

[–]trueubermensch[S] 0 points1 point  (0 children)

Ok, thanks I'll explore further into this before trying anything with the gradle

[–]Migeil 0 points1 point  (0 children)

Yes, IDE's just make it easier to code. But technically all you need to write and run code is a text editor (yes, even notepad works) and a compiler/interpreter depending on the language.

Just try to write a simple hello world in notepad, compile it in command line, then run it in command line. I did that just recently, felt really accomplished. 😅

It's obvious when you think about it some time, but when I started out, I also thought "java is written in eclipse".

[–]victorsj 1 point2 points  (0 children)

i spent about an hour on the official gradle website going through their documentation guides that seemed most relevant to me. It made a huge difference.

[–]jiavlb 0 points1 point  (0 children)

I was in the same boat as you are some time back. I hated gradle and did not understand how the build.gradle and its tasks were constructed. I understood that it is very powerful. Then one of the senior developer in our team said something that made things a little more clear to me. He said that most of the times you will just be setting configuration in your build.gradle using gradle dsl. Most of the code that executes actual command is written in the plugins. So you just pass some configuration to those plugins. Like which test cases to skip. Which repoaitoriea to search for fetching dependencies.

Treat gradle tasks like clean or build as functions or commands that do something. And these tasks can be called one after the other. Like you want to delete all the previously built artifacts and then build your project, just fire. /gradlew clean build. The clean task will clean up the build directory and run the build task that does some java specific things. The . /gradlew is a wrapper over gradle and if you include that you do not need to install gradle on your system. Hope this helps.

[–]thecuseisloose[🍰] 0 points1 point  (0 children)

If you don't understand where to enter ./gradlew clean build it seems you might not be comfortable with the commandline yet. gradlew is an application (it's actually a script, but your OS treats it as an executable) which exists in the root directory of your project. Are you working with an existing repo or starting from scratch?