gmethvin / sbt-tld

An sbt plugin to generate a current list of top-level domains

Version Matrix


Travis CI Download

An sbt plugin to generate a current list of top-level domains for use in Scala.


This plugin requires sbt 1.0.0+. Reference it in your project/plugins.sbt like:

addSbtPlugin("io.methvin.sbt" % "sbt-tld" % version)

where version is replaced by the latest version: Download

Then add the TldPlugin to the project for which you'd like to generate the TLD list, and configure the settings to your liking:

enablePlugins(TldPlugin) // this is required on the project in which you want to generate the TLD file

// all these settings are optional; default values are shown here

// amount of time after which to regenerate the TLD file
tldRegenAfter :=

// name of the package in which to put the TLD object
tldPackageName := "io.methvin.tld"

// name of object wrapper in which val is created
tldObjectName := "TLDs"

// name of val containing the list of TLDs
tldValName := "get"

// URL from which to get the list (one TLD per line, lines with invalid TLDs ignored)
tldSourceUrl := new URL("")

You can configure the package, object, and val names by setting the above-mentioned settings. Note that these values are substituted into the code unescaped, so they must be valid identifiers in each context.

This will generate a file that looks like:

package io.methvin.tld

object TLDs {
  val get: IndexedSeq[String] = IndexedSeq(

In this case, to get the list of TLDs, you'd use TLDs.get. For convenience, the TLDs are all lowercased and sorted.