Kotlin / kotlin-frontend-plugin

Gradle Kotlin (http://kotlinlang.org) plugin for frontend development
Apache License 2.0
563 stars 69 forks source link

Can't build, a problem occurred configuring project ':kotlinfrontend' #29

Open KirkBushman opened 6 years ago

KirkBushman commented 6 years ago

Hi, when I try to build I get this error message, I tried multiple configurations of gradle I found online, but nothing works...

this is the message:

* What went wrong:
A problem occurred configuring project ':kotlinfrontend'.
> Failed to notify project evaluation listener.
   > Could not create task of type 'GeneratePackagesJsonTask'.
   > Cannot add task ':kotlinfrontend:npm-preunpack' as a task with that name already exists.
   > Cannot add task ':kotlinfrontend:npm-preunpack' as a task with that name already exists.

this is my current config:

 apply plugin: 'kotlin2js'
 apply plugin: 'org.jetbrains.kotlin.frontend' 
 apply plugin: 'kotlin-dce-js'

 repositories {
      jcenter()
  }

dependencies {
      compile "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version"
      compile "org.jetbrains.kotlinx:kotlinx-html:$html_version"
      compile "org.jetbrains.kotlin:kotlin-test-js:$kotlin_version"
      testCompile "org.jetbrains.kotlin:kotlin-test-js:$kotlin_version"
}

 kotlinFrontend {
     downloadNodeJsVersion = "latest"

     npm {
         dependency "style-loader"

          devDependency("karma")
     }

     webpackBundle {
           bundleName = "main"
           contentPath = file('src/main/web')
     }

     define "PRODUCTION", false
}

 compileKotlin2Js {
       kotlinOptions.metaInfo = true
       kotlinOptions.outputFile = "${projectDir}/web/js/app.js"
       kotlinOptions.sourceMap = true
       kotlinOptions.moduleKind = 'commonjs'
       kotlinOptions.main = "call"
   }

Someone knows what is going on? Am I doing something wrong? Thanks in advance...

cy6erGn0m commented 6 years ago

Looks like you are applying plugin multiple times. Is it multimodule project?

KirkBushman commented 6 years ago

Yes I have the base project which has nothing, and two subprojects that are the backend and frontend

 subprojects { p ->
      p.buildscript {
         ext.kotlin_version = "1.1.61"
         ext.kotlin_frontend = "0.0.23"

         repositories {
              jcenter()
              maven { url "https://dl.bintray.com/kotlin/kotlin-eap" }
         }

         dependencies {
             classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
             classpath "org.jetbrains.kotlin:kotlin-frontend-plugin:$kotlin_frontend"
         }
     }
}

subprojects {
    ext.kotlin_version = "1.1.61"
    ext.ktor_version = "0.4.0"
    ext.html_version = "0.6.8"
    ext.gson_version = "2.8.2"

    repositories {
        mavenLocal()
        jcenter()
        maven { url "http://dl.bintray.com/kotlin/kotlinx.html" }
        maven { url "http://dl.bintray.com/kotlin/ktor" }
    }
}

this is the main project's gradle file

fhchina commented 6 years ago

I have the same problem:

Failed to notify project evaluation listener. Could not create task of type 'GeneratePackagesJsonTask'. Cannot add task ':npm-preunpack' as a task with that name already exists.

fhchina commented 6 years ago

And this is a simple single gradle file/project.

KirkBushman commented 6 years ago

For what is worth, I tried downloading the full stack sample provided, and it still gives this error... I'm stuck...

cy6erGn0m commented 6 years ago

What gradle do you use? Is it reproducible with sample project from repo?

KirkBushman commented 6 years ago

Gradle 4.3.1, using the latest intellij 2017.3, updated today, the problem is still there

KirkBushman commented 6 years ago

Ok, I'm not an expert, but I think it has a problem with gradle in my machine: If I remove the kotlin-frontend-plugin, I can build using both "gradle build" or "./gradlew build". If I'm using the kotlin-frontend-plugin, I can only build using "./gradlew build".

The error I have reported above comes out if I use "gradle build".