creating a new junit 5 project in gradle in intellij

I haven’t created a new JUnit 5/Gradle project in a IntelliJ in a long time. When doing so today, I ran into a number of problems. I wound up just starting over, but writing up what I encountered/learned.

Java 16 vs 17

IntelliJ supports Java 17. When I set up Gradle, it told me that Gradle doesn’t yet support Java 17. I confirmed on the Gradle website this is true. Ok that’s fair. Java 17 isn’t fully released for another month. While there might be an early adopter package that does work with Java 17, my focus here is JUnit 5, no, Java 17. So I went with Java 16.

String not found – “Package java.lang is declared in module java.base, which is not in the module graph”

This surprised me. I’m not using modules in this project. Or at least I don’t want to be, nor do I have a module-info.java file. I tried invalidating the IntelliJ cache and restarting the IDE. That didn’t work. I then tried deleting the .gradle and .idea directories and reopening IntelliJ. That worked. IntellIJ even asked if I wanted to trust the gradle project as it recreated one.

This approach lost all IntelliJ settings including Java version, gradle version and source/test directories.

Recreating the project

At this point, I decided to delete my build.gradle and settings.gradle files in addition to the .idea and .gradle directories. My plan was to start over. I then created a new Gradle project in the same directory. I created a dummy file and had IntellIJ create a JUnit 5 test for me. That updated the Gradle file in a way that the IDEA was happy with. Now to commit to git lest anything else happen.

Responding to a co-located/fully remote/hybrid article

I read Should Your Organization Be Co-Located, Fully Remote, or Hybrid from Scrum Inc. It’s nice to see the agile community starting to accept that co-location isn’t necessary to be an agile team. (I’ve been on a team for many years with people in multiple locations and it never stopped us from doing Scrum. We even figured out how to make in person agile games remote. A few takeaways/responding

Feedback

I really like this quote

Uncollected feedback is perishable; the longer you wait the less reliable it is

Many years ago (even before doing Scrum or remote.), I noticed that people had trouble recollecting what they wanted to contribute to the retrospective. They were quiet at meetings and didn’t remember problems not fresh on the mind.

I solved this by putting a shoebox and post its in a common location. This let the team put in their thoughts right as they happened.We had someone organize the post its by topic and used the retrospective time to discuss them.

Over time, that shoebox became electronic. But the benefits still stand. Real time opportunities to record those thoughts. I really like the perishable quote and am sharing it with my current team at our next retrospective!

Purpose of an office

The article lists the following benefits of an office. It was interesting reflect on how much of this applies to me and my troubles over the last 15 months. The table shows my thoughts on them both for work and the high school robotics team I mentor

Item from articleWorkRobotics
Collaboration, communication, and the sense of belonging that comes with colocationI’m not sure. It’s definitely good seeing people, but my team has been distributed for years. So a lot of my connections were with people not on my team anyway.Definitely. The kids noticed how much they feel not being able to hang out, have team dinners, bond over dodgeball, etc
A place to work away from the distractions of homeYes! This is one of the problems I’m having. (I put not having a good physical work space in this area. A subpar work environment is certainly distracting.)Some of the students share rooms or have distractions on calls.
Creation of physical products and use of specialized tools n/a – our tools are computersDefinitely. Not having access to the lab, tools, robot greatly limits what can be done.
Space for gatherings and training While I don’t need to see my teammates every day/week, we do all meet in person on occasion. In person meetings allow for more flexibility and cross training
A need to directly interact with customersn/an/a
A place to focusAnother one for me. I only have so much energy to focus at home. It’s less than 8 hours worth which isn’t even enough for a day let alone fun things after work. I also notice, I can’t carry as many thoughts in my head at home.Not sure.
The status and stability a physical location conveysn/an/a

Sustainablility

Another quote I found interesting:

Working more hours to get less done is not a recipe for success. 

For most of the weeks of the pandemic, I refused to work more hours. (I made an exception for the a month and there was a high cost. I’m still recovering to get myself to the point I was at the week before I made that exception.) I got less done but it wasn’t from more hours.

Most of my colleagues get the same or more done at home. They should be able to to telecommute forever! I am not one of those people. At the office, I have a desk so I can see more stuff at once. I have two monitors so I can work faster. I can hold more thoughts in my head

And also

There will be times when after-hours work will be needed. These need to be the exception – not the rule.  

I agree with this. And I made that monthlong exception intentionally. Also my employer passed the “test” of it being important. I worked one weekend day in exchange for a comp day. So at least it was my employer’s time too, not just mine.

I hear a lot of people say “since I’m not commuting, I can work more.” I strongly disagree with this. I used my commute time productively. I read the news in the morning and a computer book on the way home. (My computer book reading is also down because my at home energy isn’t available when I have time to read now.) Commuting time belongs to me, not my employer. It being gone isn’t a reason to work more hours.

Hybrid workspace ideas

The article also lists some ideas for hybrid work. My thoughts on those

IdeaResponse
Have designated team days for in-person workWe did that when we were a colocated team with telecommuters. (Monday was the day nobody could telecommute.) I consider this a crutch that we long moved past. Luckily we became a multi-city/time zone team after I no longer needed that crutch!
Institute policies to fight ‘Zoom Fatigue’ and burnoutThe article suggests holding 10 minute breaks between meetings. I’ve had meetings 9:05-9:55 for as long as I can remember. So meetings i control do come with those breaks.
Always hold team events in virtual conference spaceThis one we didn’t quite do. We did have people at the same site connect from the same room rather than everyone being at their desk. But everyone did contribute equally. It wasn’t most people in one room and a handful alone at home.
Publish all meeting notes in a visible space which can be accessed remotelyEverything is electronic. While we do publish notes, we aren’t an async team though.
Only use virtual whiteboardsDefinitely! The only time we used physical whiteboards was for pairing when the two people involved happened to be in the same location.

opening multiple intellij modules in the same project and remembering them on reopen

This is the number one problem that has prevented me from using IntelliJ more and I finally know how to do it. (I’ve known how to open multiple modules for over a year. What I learned yesterday at the IntelliJ 20th anniversary conference was how to reopen that same set)

Note about terminology to Eclipse users

If your primary IDE is Eclipse, keep this difference in terminology in mind as you read this.

EclipseIntelliJ
WorkspaceProject
ProjectModule

Step 1: Create a dummy/grouping project

Create a new project. This project’s purpose is to contain the modules you want together and give it a distinct name. I’ve been keeping them in an IntelliJ folder in my home directory to avoid confusion. (Most of my stuff is under the git folder in my home directory). The idea of keeping them separate is so I know there’s not code in there.

Step 2: Add your modules

There are several ways of adding modules. Any of them are fine. I find the fastest for repeated adds is:

  • File > Project Structure > Modules
  • Click “+”
  • Choose “Import module”
  • Navigate to the build file (ex pom.xml) or .iml file for generic projects

Step 3: Rename the project (if needed)

On rare occasions, I noticed the project name got my first module name. I couldn’t reproduce this, but started double checking. This name is what will show up in your recents list.

  • File > Project Structure > Project
  • Enter a new name if needed

Testing

File > Open Recents and open another project. Then File > Open Recents and open this project. Admire how all your modules are back!

Seeing the modules on disk for the curious

In the dummy project, the .idea directory has a misc.xml file. I was told it contains all the modules. And it did when I tested on Windows

<list>
  <option value="$USER_HOME$/git/myProj/pom.xml" />
  <option value="$USER_HOME$/git/myProj2/pom.xml" />
</list>

When I tested on Mac, modules.xml had this info

<modules>
   <module fileurl="file://$USER_HOME$/git/myProj.xml" filepath="$USER_HOME$/git/myProj.xml" /> 
   <module fileurl="file://$USER_HOME$/git/myProj2.xml" filepath="$USER_HOME$/git/myProj2.xml" /> 

</modules>

And a note about “you are doing it wrong”

I am an Eclipse power user and an IntelliJ competent user. What holds me back is not using IntelliJ more at work because of not knowing how to do this. While I don’t want to replace my usage, I do want to be an IntelliJ power user and use Eclipse enough to not lose my skills! I think this is the thing that will do it!

When I’ve tried to find out how to add multiple modules and have them remembered multiple times in the past, I was told that I was “using IntelliJ wrong” and should have one project that I focus on. (I work on many sets of small related projects; that model doesn’t work for me.)

Yesterday, someone attempted to tell me that I should have one big project that I focus on at a time. (aka my problem doesn’t exist.) After explaining what I do, another user said he does that I do. The first user said something about religion. That seems like just it. There’s multiple religions. It’s fine to be passionate and a true believer in yours. But as part of society, accepting that other people believe differently is part of life.