We need to talk about Gradle

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello it's Duncan the aim of this channel is to document the working practices of a half decent software developer so I pretty much show all the changes that I make to the source code of a project there's one exception to this convention which is that I don't subject you to the chores that are required to keep the build up toate I upgrade things fiddle to make things faster even sometimes upgrade Gradle itself all on my own time today they I try to modify the build of the jet brains ker example project that we've been studying in recent videos I just wanted to get it to build and run on jdk 21 so I could run benchmarks with loom virtual threads I failed as failing to get gradal to just do something is in my experience part of the working practices of a half decent software developer I've decided to make an exception to my exception and publish the attempt I'm probably missing something obvious maybe I just need to rtfm No Doubt there is a solution but the S fact is that we're grad is concerned even my 35 years of Industry experience isn't enough to keep me from stumbling around in the dark what is it doing you join our Intrepid Hero after I've just pasted the throughput tests from the project we were working on last week into our Kor Cod snippit project and that's from the Kor examples and I've changed the build. gradal I've added in HTP Fork server Jetty and client OK HTTP so that we get compiling a bit but we seem to have issues here with Jupiter and that I think is because the Kor examples are using junit 4 although I think behind the facade of Cotman test so let's see if we can get this compiling the test came from this project here and the bill. gradal file in there has a here we are test tasks used jit platform so let's take that come back here and into our build. kts we'll put that and we see down here here that appears to be all right so let's try running all of our tests run tests okay so we're still not seeing Jupiter which is Jor 5.8.1 but apparently we can add that to the class path let's try that download it from aen repository you see I don't want to add it to the class path for here I want to add it to the class path for gradal don't I uh well never mind it's given us a coordinat so let's try that that cancel that go here and say maybe just maybe if we say our test implementations are going to depend on that let's try that okay number of things coming down and including engine and so on so let's see whether that builds oh and it does good BL the tests uh okay slow fun jety uh that doesn't exist uh my bad let's just get rid of that one all together I've got rid of a whole bunch of tests here just leaving a Handler behind trying to get it to compile let's run again okay and operation is not implemented okay so we are on the case good instead of to do then let's make this an empty Handler so that's a Lambda that takes a request and returns a response of status okay don't think we need a body Jetty Loom is not compiling that's a bit strange as it compiled just up to then let's try a build I suppose we kind of did lose the type of this let's tell it that this is actually HTTP Handler and that seems to make things okay so build again and run the tests okay so preview features not enabled need to run with minus minus enable preview where's that virtual thread Jetty Loom okay so here when we try and build Jetty Loom is not able to create virtual threads so we are I guess not running with Java 21 where that's no longer a preview feature so we'd like to be Java 21 let's see if we can fix that just going to see no it's not telling us what the Java version is let's go to the command line and we're in the right place so we'll say Java minus version okay so Java Plano Java appears to be Java 1.8 uhhuh uh how about what gradal thinks that's up one up one gradal W minus minus persan and gradal is running with cotlin 1.7 and Java 1.8 although I don't think it can actually be trying to run the app with 1.8 because I wouldn't know anything about Loom preview features let's see if I can out what jvm gradal is using to build and run our app so this is the build file for the project we're running in it says cotlin jvm but nothing else uh no other clues that look like a version to me okay maybe we should go up to the build. Gradle or settings. Gradle up above so there's no build.gradle at the top level but there is a settings. Gradle which doesn't mention the Java version at all okay returning to the project where this did work I note the next thing down here is cotlin jvm tool chain so that may be a good idea uh nothing else in there that looks significant so let's go and P that copy it from there and we'll put that into this project which is this build. kts here so we C cut in jvm and then we're configuring it with jvm tool chain if I save that yes grle is doing some stuff so that evidently is a change good and now we'll run again and now unknown cotlin jvm Target 21 H well no other output just that but that was because we said jvm to chain 21 so at least it's taken some notice of that number I wonder if on the command line we now ask radel what it's running with and the answer is well it's still using 1.8 although I think that's just the version It's itself running with not the version that it's using to compile but I do notice there quite a few versions of grad out grad is now at 8 something whereas this example project still has 7.6 so with some trepidation because this is gradle's instructions for upgrading our build and it talks about deprecations and so on and upgrading plugins and Y yadada I'm just going to go with throttle up and try and run that see how we go back to intellig and I'm going to do this at the root so I'm going to go up a couple code Snippets yes that is a root of everything so now I'm going to do the thing that Gradle told me to do which is that obviously not actually that it's SLG gradal W so let's run that okay that was very quick let's now try going back to where we were oh no actually I should just ask gradal what its version is so that's grad wus minus version and oh everything looks better so now we're running gradal 8.7 which is using cotl 1.9.2 two and some other stuff but the jvm that gr itself is running on is still 1.8 uh but maybe there's a chance now that the new version of gradal will recognize Java 21 as a thing so let's try that we'll go back to where we were and we will run/ gradal W clean test and see how we get on oh but notg grad W do do do dogr W oh but there once again we have unknown cotlin jvm Target 21 that's a bit strange it says we can run with info or debug to get more output so let's try that I won't bother to do the clean but let's just say minus minus debug oh my goodness lots of stuff okay and I'm going up and have a look well stuff about caches and completing builds and stuff and stuff and [Music] stuff it's so much stuff that would be lost at the beginning of that when the scrollback buffer think I'm going to try and minus minus info see whether that's more sensible well it was certainly shorter transforming some stuff who knows what that is about some Demon stuff settings evaluated okay so this looks like when we actually start configure project la la la anything about Java nothing about Java brilliant just going to check we get the same behavior if we just try running the tests and we do that's good let's ask AI assistant about this so we take that thing and we say explainer message with AI and y y y but fundamentally it's too old and says Java 21 does not exist yet so that's no help let's try Google well that purple link suggests I've been here before let's have a look welcome to gr 8.4 compiling and testing H could not determine the dependencies same here still not a bug cotland still not support jdk 21 but the thing is I know that not to be true now because the project that this code came from works okay think of something else let's give AI assistant all of this file and then we'll say new chat using selection this gradal build fails with unknown cotlin JM Target D1 can you fix it release oh and the same problem Cur you how would I make it work if Java 21 did exist got L jvm Target equals 21 okay well I think that that's the same as that so I don't know I'm a bit stuck let's go back to command line and I wonder whether we can get somewhere by having the current Java version to be 21 so at the moment I got Java minus version is still 1.8 but I have jnv installed and I think that would mean that I could go here and say file call it Java hyphen version actually we can look in here and see what I do here so this has yes dot Java hyphen version and in this case it's 17 which is interesting because we are actually building on the 21 but never mind let's copy that and let's just paste it into here so this is a Java version file that's known to make the other place work just check whether JM is doing its job and it is they are like 17 so now let's try building again unknown jvm Target at 21 somewhat desperately I'll make this 21 and then Java's version will be 21 let's ask gradal what it thinks it's doing minus minus version so gradal is now running on Java 21 but when I ask it to run let's just say clean okay so it's able to clean that's good and then build no and unknown cotland jvm Target 21 somewhat in desperation I've changed my search to grader 8.7 unloan cotland jvm Target 21 and I apparently have one hit in all the world which is the one we just come from let just go down the bottom and see whether anyone mentions 8.7 in here and 8.7 still not Java 21 question mark who who knows so the only mention of 8.7 is in fact somebody questioning whether it works and well we know it has worked so I am still very confused there might be a clue in the fact that when we started and tried to run we could at least build and we had instructions that we needed to enable preview which suggest that we certainly weren't running under Java 1.8 at that point so I wonder whether to remove that bit and try and build so that apparently does build okay and I guess we just going to have the same issue when we run yes there we go but I guess now we've got running Java code we can ask what it's running under also I notice it compiled so that at the very least wherever it is down the bottom here here we are this executive's virtual new virtual thread per task executor it must have been compiling against a version that knew about that okay so now I'm going to go back here and I'm going to say before we run this print L what do we want we want the Java version I'm going to say it's runtime get runtime ah runtime version there we are let's see what we get and there's your answer version 19.0 something but 19.02 something wasn't a thing that we've mentioned anywhere in here that I know of let's see if we can find where that's coming from well in the whole of this project Source apparently there is9 and that's not it no definitely not what about intellig settings I suppose that could be it let's have a look so in here we have sdks well you see I have an elegant efficiency of those this project ah we have set here 19 interesting if I set that to 21 and apply that okay how do I do um I don't understand that didn't I take that away build. gradal unknown cotland jvm Target 21 um hm okay so no don't understand I suppose that change probably meant that this thing happened I don't know um really don't let's go back here and say so that was 21 modules thing uh who knows searching for Clues not seeing anything facets artifacts no so back to project I'm saying I want you to build with 21 if I take this back to what it was before who can remember I think we said 17 did we okay that let's try that oh well it seems that 17 didn't know about virtual thread for task executor but things confusing me is I thought the jvm would be specified in some way by either the gradal build itself or at least the version of java like this one that is in Scope when the gradal build happens return here say that my project wants to be 19 okay run and we're back to enable preview one thing I have just thought of maybe I need to say build tools gradal oh but no apparently I'm building and running using gradal by default ah gradal jvm is set to 19 maybe if I set gradal jvm to 21 do that okay um now let's try no still unknown 21 um no I just don't know okay I've just remembered a thing and that's tool chains don't really know what they mean but this says I can say something like this to configure my Java tool chain now I sort of thought that might be what was going on here when we said jvm toolchain 21 but maybe just maybe I need to do the Java thing as well and say I want 21 in there let's give that a go uh no still unknown J Scotland jvm Target 21 and that is without this commented in but it appears to be because I said use 21 there don't say 21 there and I say 19 there which I think was the default before okay and try building that then I still get that uh is that because of the thing in here where I'm saying I want to build against 19 no cuz that's 19 and now 21 I don't know re build the project maybe no we're back to we're now saying 21 but a changes are that's just the version of gradal the build. gradel has changed to be let's see how so that mentions 21 that mentions 21 if I comment this out now so that there are no changes talking about Java versions at all okay rerun oh okay so so that is significant we're now running on 19 so either well so yes it kind of feels like this and this both saying the same thing as is the intellig setting but none of them want to make it 21 so I kind of feel that that and that are equivalent because that says unknown 21 that says unknown 21 but if I do none of the things I'm running on 19 which appears to be because it's set in here there I think so not for the first time afraid I have a bit of an intellig gradal sense of humor failure that's bad news for getting this project running but the good news is that next week I'll be at cotc and I will to take this jet brain stand and that somebody will be able to tell me what Arcane bit of gradal I haven't configured in some way here's hoping if you want to see that resolution then please subscribe to the channel maybe even switch notifications on so you hear about it straight away obviously you should like this video assuming you like this video and if you see me at cutl comp then please come up say hello if you can push your way through the crowds of adoring fans and finally if you have a copy of the book that I wrote win that price called Java to cot refactoring guide book then bring it along because we'll both be there and can sign your copy thanks for watching
Info
Channel: Refactoring to Kotlin
Views: 1,945
Rating: undefined out of 5
Keywords:
Id: lKIZA8PiQ3Y
Channel Id: undefined
Length: 20min 45sec (1245 seconds)
Published: Fri May 17 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.