title: "Could not find or load main class" error for Gradle-generated Scala JAR
body: <p>After much research, I can't seem to get to the root of a problem I am having in generating a runnable Scala jar file using Gradle. I'm overriding the 'jar' Gradle task to create a jar file (dependencies included) that executes starting from my main class file. However, whenever I run it, regardless of what I use for a Main-Class attribute, the console throws a "Could not find or load main class" error. Here's what I have so far:</p>
  
  <p><strong>build.gradle</strong></p>
  
  <pre><code>buildscript {
      repositories {
          mavenCentral()
      }
  }
  
  apply plugin: 'java'
  apply plugin: 'scala'
  apply plugin: 'application'
  
  repositories {
      mavenCentral()
      // some other repos
  }
  
  version = '1.0'
  sourceCompatibility = 1.8
  targetCompatibility = 1.8
  
  mainClassName = "com.test.Main"
  
  dependencies {
      // my dependencies
  }
  
  jar {
      zip64 = true
  
      manifest {
          attributes "Main-Class": "$mainClassName"
      }
  
      from {
          configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
      }
  }
  </code></pre>
  
  <p><strong>src/main/scala/com/test/Main.scala</strong></p>
  
  <pre><code>package com.test
  
  object Main {
    def main(args: Array[String]): Unit = {
      print("Hello world");
    }
  }
  </code></pre>
  
  <p>In fact, when I run "java tf test.jar", it shows "com/test/Main.class" in the root of the jar! Am I missing some important class path info or something? I'm running Java 1.8 on macOS Sierra using Gradle 3.5. Any help is appreciated. Thanks! </p>