Switching your Gradle builds from JCenter to Maven Central

JCenter is being decommissioned on May 1st, 2021. Since many Gradle builds use JCenter by default, this means your Gradle build file is likely to have jcenter() in it. This means you have a few months to switch to Maven Central. Don’t worry, it’s easy.

Note: If you work for a company, you are hopefully using an internal binary repository proxy. (ex: Nexus, Artifactory, etc)

What’s the difference between JCenter and Maven Central?

The main benefits of JCenter are:

  • Some artifacts are in JCenter and not Maven Central – their authors are working on moving them to Maven Central. This is unlikely to affect FRC teams, but might affect people using an artifact that is more specialized.
  • It’s easier to publish to JCenter – Sonatype has been working on making it easier for Maven Central. Some of that is intrinsic though because Sonatype does a lot of verification.
  • JCenter is faster – Remember that artifacts are cached on your machine. So once you’ve downloaded the artifacts, your build performance is the same.

How do I find the affected files in GitHub?

Searching on github for either of these does not do what you might expect

  • jcenter user:boyarsky filename:build.gradle- the code tab returns 0 results
  • jcenter org:stuypulse filename:build.gradle – the code tab returns 2 results

That’s because github search only looks in files that have been updated or returned in search results in the past year. Unfortunately, the last year has not been particularly representative of a normal year. And people edit/search the contents of build.gradle files way less frequently than other file types.

I recommend just searching for the filename. That returns all your build.gradle files so you can edit them. (And since you are probably consistent in your choice of binary repository, you can sample a few matches to see if you have to change.

  • user:boyarsky filename:build.gradle – the code tab returns 5 results
  • org:stuypulse filename:build.gradle – the code tab returns 24 results

Tip: You may also have a reference to jcenter in your settings.gradle so I recommend searching that as well.

How do I edit the file?

GitHub has good Rest APIs so you can script this if you have a lot. If you don’t have a ton, either of the following is viable. (I had 5 build.gradle files in my personal repo and 3 of them were already using Maven)

Option 1 – Use the browser

  1. Open each link from the code tab of the search
  2. Choose the default branch (ex: main/master) from the pull down – search often returns a specific commit
  3. Drill down to the build.gradle file if not already there.
  4. Click the edit/pencil icon in the top right (just above the code)
  5. Change jcenter() to mavenCentral()
  6. Enter a commit comment and save
  7. If you want to make sure your build still works, run it (ex: Travis)

Option 2 – Clone the repos

(Tested on Mac; I don’t have Git Bash on my home computer so don’t know if it works exactly the same. I have used find on Git Bash though so I think it does)

  1. Clone the affected repos (if you don’t already have them)
  2. Go to a parent directory of the github repos (ex: <userHome>/git
  3. Run a UNIX command to update the list files find . -name build.gradle
  4. Run a UNIX command to update the affected files: find . -name build.gradle -exec sed -i ” -e ‘s/jcenter/mavenCentral/g’ {} \;
  5. Commit/push the affected repos (listed in step 3)
  6. If you want to make sure your build still works, run it (ex: ./gradlew build)

Coding is easy and other fallacies

The New York Times ran an op-ed with the headline “In India, parents are being aggressively sold the idea that their children must start coding at 4 or 5 or be future failures.” (It’s behind a paywall, but you don’t need to read the article for my blog post). As I read the comments, I kept cringing at some fallacies. Hence my blog post. I’ve paraphrased the arguments I want to respond to.

My opinion: I don’t think little kids need to learn how to do code as little kids. But I also don’t think it is terrible if they do. Languages like Scratch Jr let kids create cute stories and games online. This feels just as creative to me as coloring except with some logic built in.

“Coding is easy”

I wrote a whole blog post about what “easy” means. I assure you many people currently learning to code (as adults) are not thinking “this is easy”

“No need to learn early; I learned to code in 3 months at age X”

Learning to code is not the hard part. Being a programmer/software developer is more than just learning how to code. Knowing how to code is a foundation skill for being a good programmer though. (Kind of like how basic arithmetic is a foundation skill for algebra). Once you’ve learned that initial three months of coding, you can learn the harder things that make you a good developer. For example, knowing what libraries/frameworks are available allows you to solve problems far faster.

I agree that you can become a good developer at any age. But I disagree that three months is enough to become proficient. Also, I’m sick and tired of interviewing “experienced developers” who can’t solve the equivalent of FizzBuzz. That’s a foundation level skill.

“Nobody will need to code by the time these kids grow up”

I’ve been reading about coders become obsolete my entire career. And I’m sure the predictions didn’t start then. Programming will become higher level over time. It already has. Look for some assembly language developers. Look at some Fortran code. It would take a long time to write something in those languages that we could write in minutes in a modern language.

Similarly, there are DSLs (domain specific languages) for business users. Who writes these? Programmers!

I also expect more “glue” and customization code over the years. I work with a lot of COTS (commercial off the shelf) products. One would think that there wouldn’t be a lot of programming because someone else wrote the product. Yet I code almost every day. Sometimes all day. Businesses will always have custom requirements.

“Languages change too quickly to learn”

Let’s look at some dates here. Python and Java were both created over 25 years ago. Both languages have changed extensively in the last 25 years. So yes, learning 1990’s Python or Java would not make you a good developer today.

However, these are little kids. They are probably using a language like Scratch that doesn’t require reading. Which clearly won’t be the language they use when they grow up. Similarly, the won’t be reading picture books when they grow up either (comics maybe, but not picture books.) When I was in elementary school, I learned Logo (a language with a turtle.) It was fun. I learned a little about computers and math and made a turtle move.

Even as an adult, you need to keep learning as programmer. Languages change. There are new languages. Learning multiple languages up front helps you learn new ones faster over your career. The fact that something changes quickly doesn’t mean declaring defeat.

Copy/paste connected shape in Acrobat Reader

Adobe Acrobat Reader DC has a “shape” called “Connected Lines” in the comments pane. I wanted to copy/paste and move one around. This was a pain in the neck. I wasn’t expecting it to be that hard.

I ran into three problems:

1 – Pasting only works in a certain mode

I select the shape with ctrl-C. If I press ctrl-v to paste, nothing happens. Why? Apparently because I have the comment feature open. If I open the stamp feature or click “close” so nothing is open, it does paste. Ok fine. Except…

2 – It doesn’t paste where I put the mouse cursor

When I get it to paste, it always seems to be the center middle of the screen towards the bottom. This is rarely where I want my pasted item. This would be a minor annoyance except

3. It doesn’t let me drag with the mouse

A text comment box, I can select with my mouse and drag where I want it. A connected shape changes the shape when I try to select it. I can use the arrow keys to move it but that is slow and tedious… Oh wait. I figured it out. If I mouse over very carefully to the center of the connected shape, my mouse turns into a drag icon and I can drag it with my mouse.