GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — INCLUDE DependsOn with class packages in different namespace · Issue #334 · kscripting/kscript

INCLUDE DependsOn with class packages in different namespace #334

New issue
Copy link
New issue
Copy link
Open
Open
INCLUDE DependsOn with class packages in different namespace#334
Copy link

Description

@HoffiMuc
HoffiMuc
opened on Nov 29, 2021
Issue body actions

In my case, I have my main in package x.y
and want to INCLUDE / DependsOn a file in package x.a as well as in package x.y.z

@file:DependOn(...)

@file:Include("../helpers/CamelCase.kt")
@file:Include("./mappings/Jira.kt")

@file:EntryPoint("com.hoffi.something.AppKt")

package com.hoffi.something

import DependsOn
import EntryPoint
import Include
import com.hoffi.something.mappings.Histories

fun main(args: Array<String>) {
    App().main(args)
}

class App : CliktCommand() {
    override fun run() {
        ...
    }
}

doesn't find the class which is one of the defined classes in ./mappings/Jira.kt

package com.hoffi.something.mappings

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import java.time.Instant

...
@SerialName("histories")
@Serializable data class Histories(
    val author: Author,
    @Serializable(InstantSerializer::class) val created: Instant,
    val id: String,
    val items: MutableList<Items>,
)
...

gives me:

/tmp/tmp17398417963705588090.tmp/scriptlet.248cdc652452029b.kt:18:18: error: unresolved reference: something
import com.hoffi.something.mappings.Histories
                 ^

btw: ... it took me a long time to really understand your comment you added in ee7748e

Activity

  1. holgerbrandl commented on Nov 30, 2021

    @holgerbrandl
    holgerbrandl
    on Nov 30, 2021
    Collaborator
    More actions

    I guess this use case is not supported, and it's unlikely that this will ever work. @file:Include works by literally rewriting your script code prior to compilation to include the include-file at the given location. kscript tries to be a bit more clever, to at least sort imports to the top of the merged script. But it can't resolve the conflict you've created in your example where a single source file has 2 package statements. This is not legit according to the kotlin language specification.

    Does this answer help?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402520 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.