tasks.register("artifacts") {
  group = "Help"
  description = "Displays the artifacts associated with each configuration of " + project
  doFirst {
    configurations.findAll().each { config ->
      println "${config}:"
      config.allArtifacts.getFiles().each { file ->
        println " " + file
      }
      println ' '
    }
  }
}

/** Find a random, reusable port. */
ext.randomOpenPort = { ->
  final ServerSocket socket
  try {
    socket = new ServerSocket(0)
    socket.setReuseAddress(true)
    socket.close()
    return socket.getLocalPort()
  } catch (final IOException ioe) {
    ioe.printStackTrace()
    return -1
  }
}
