I am reading a book on Gradle, little bit old from...
# gradle
n
I am reading a book on Gradle, little bit old from 2012 or something like that. There is a
<<
syntax I encountered which is an alternative of
doLast
. Here is a snippet,
Copy code
3.times {
 task "yayGradle$it" << { 
 println 'Gradle rocks'
 }
}
but it isn't working. I anticipate the syntax my have been deprecated. Can anyone point out which version I can use to run that snippet?
j
doLast
I recommend to you to use kotlin dsl
it has autocomplete and control B works :)
n
I will use Kotlin but I want to follow the snippets of the book
Isn't there any way to do that?
j
task.register(name) { doLast { … } }
g
<< syntax is discuraged even for Groovy. It's eager API (so it works not exactly the same as suggested "register") I wouldn't probably spent time on such an old book, it will not help with modern best practices, 9 years is a huge time, especially for software which releases new version every month, and instead would start from official guides
n
@gildor Yep, now I am doing that. Actually, I needed some background in Gradle. I tried first with a hands-on tutorial. Still the same overwhelmed feeling. Later on I found that page. It's the "Authoring Gradle build" section. Gradle is probably the most "less-demystified" technology that I have ever come across. Almost no helpful tutorial on Youtube. And most of the articles are providing some kind of "hands-on". Nobody is talking about the fundamentals. So, yeah documentation is the safest bet here.
👍 1
@gildor @Javier thanks both of you 🙃
g
There is just an incredible amount of good tutorials about Gradle
It really depends on what you are looking for
n
Then I have surely missed something obvious. Can you share one? That would guide me piece by piece? I don't want something that would just spit out hundreds and thousands of files once I run
./gradlew build
. I want something that talks about more fundamentals. So that I can understand what's going on.
g
From recent videos I would highly recommend this series, it covers some core concepts of Gradle https://youtube.com/playlist?list=PLWQK2ZdV4Yl2k2OmC_gsjDpdIBTN0qqkE
n
Effectively, I can do two things, 1.
Copy code
kotlinc -cp someJar someKtFile
java -cp someJar someClassFile
2.
Copy code
a. Initialise a Gradle project using Intellij

b. write some code (maybe add some `implementation` in between in the build.gradle file)

c. and run that using some IDE features
I want something that would bridge the gap between these two.
Hmm... that playlist seems promising. Let's give it a go.
v
The leftshift syntactic sugar was deprecated in 3.2 and removed in 5.0. So if you really want to use such old snippets, you need to use a Gradle version <5.0. But I agree that a tutorial for that old versions is maybe not too helpful. 😄
👍 1
a
On the other hand, if you do go with learning Gradle 2 then you’ll be amazed when you see what each next major brings 😉