JavaCompile vs PreBuild: why JavaCompile not working?

I want build my “native” code with help of gradle.

So I create new task:

archsInfo.each { arch_name ->
  tasks.create(name: "MyNativeBuild${arch_name}", type: Exec, description: "Building core for ${arch_name}") {
    //..something
  }
  //1
  tasks.withType(JavaCompile) {
    compileTask -> compileTask.dependsOn "MyNativeBuild${arch_name}"
  }
  //2
  preBuild.dependsOn "MyNativeBuild${arch_name}"
}

without “//2” it failed when I build code first time.
It failed because of “MyNativeBuild${arch_name}” was run, but not before “java part compilation”,
it works at most of the end of build, and task that collect output of “MyNativeBuild${arch_name}” and place it to apk (I build for android) not found output of MyNativeBuild.

After I added “//2” all start works fine.

So what “//1” do? I supposed it force my task run before any compilation of java code,
but looks like I was wrong here?