cbeust / kobalt

A Kotlin-based build system for the JVM.
Apache License 2.0
432 stars 60 forks source link

kapt or multiple run{} oddity #437

Closed ethauvin closed 7 years ago

ethauvin commented 7 years ago

Project: https://github.com/ethauvin/semver-example-kotlin

./kobaltw clean run runJava

───── example:run
-----------------------------------------------------
  Example 2.17.52-beta+007
    Built on:       Thu, 27 Apr 2017 at 19:52:43 PDT
    Major:          2
    Minor:          17
    Patch:          52
    PreRelease:     beta
    BuildMetaData:  007
-----------------------------------------------------
───── example:runJava
-- From Java ----------------------------------------
  Example 2.17.52-beta+007
    Built on:       Thu, 27 Apr 2017 at 19:52:43 PDT
    Major:          2
    Minor:          17
    Patch:          52
    PreRelease:     beta
    BuildMetaData:  007
-----------------------------------------------------

All good. Try running again:

./kobaltw run runJava

───── example:runJava
-- From Java ----------------------------------------
  Example 2.17.52-beta+007
    Built on:       Thu, 27 Apr 2017 at 19:56:06 PDT
    Major:          2
    Minor:          17
    Patch:          52
    PreRelease:     beta
    BuildMetaData:  007
-----------------------------------------------------
───── example:run

run doesn't output anything any more, same if you just do ./kobaltw run.

./kobaltw runJava always works.

Not sure if that's a problem with kapt and the multiple run {}.

Wonder if we can build a test for this?

cbeust commented 7 years ago

I'll see if I can reproduce this.

-- Cédric

On Thu, Apr 27, 2017 at 8:02 PM, Erik C. Thauvin notifications@github.com wrote:

Project: https://github.com/ethauvin/semver-example-kotlin

./kobaltw clean run runJava

───── example:run

Example 2.17.52-beta+007 Built on: Thu, 27 Apr 2017 at 19:52:43 PDT Major: 2 Minor: 17 Patch: 52 PreRelease: beta BuildMetaData: 007

───── example:runJava -- From Java ---------------------------------------- Example 2.17.52-beta+007 Built on: Thu, 27 Apr 2017 at 19:52:43 PDT Major: 2 Minor: 17 Patch: 52 PreRelease: beta BuildMetaData: 007

All good. Try running again:

./kobaltw run runJava

───── example:runJava -- From Java ---------------------------------------- Example 2.17.52-beta+007 Built on: Thu, 27 Apr 2017 at 19:56:06 PDT Major: 2 Minor: 17 Patch: 52 PreRelease: beta BuildMetaData: 007

───── example:run

run doesn't output anything any more, same if you just do ./kobaltw run.

./kobaltw runJava always works.

Not sure if that's a problem with kapt and the multiple run {}.

Wonder if we can build a test for this?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/cbeust/kobalt/issues/437, or mute the thread https://github.com/notifications/unsubscribe-auth/AAFoopoO6gvYPl-tw8iY8afqpIBt3lCgks5r0VbZgaJpZM4NLACO .

cbeust commented 7 years ago

That's a funky one.

kapt generates stubs (long story) and one of these is Main.java:

~/t/semver-example-kotlin$ find . -name Main\*
./kobaltBuild/classes/com/example/Main$Companion.class
./kobaltBuild/classes/com/example/Main.class
./kobaltBuild/generated/source/apt/stubs/com/example/Main.java
./src/main/kotlin/com/example/Main.kt

For some reason (non deterministic order of assembling the jar file I guess), the second time the jar file is generated, it's this Main class that gets picked up and not yours, and since it's a stub, it's mostly empty:

package com.example;

@net.thauvin.erik.semver.Version(properties = "version.properties", type = "kt")
public final class Main {
    public static final com.example.Main.Companion Companion = null;

    public Main() {
        super();
    }

    public static final void main(@org.jetbrains.annotations.NotNull()
    java.lang.String[] args) {
    }

    public static final class Companion {

        public final void main(@org.jetbrains.annotations.NotNull()
        java.lang.String[] args) {
        }

        private Companion() {
            super();
        }
    }
}
cbeust commented 7 years ago

1.0.80.