hey everyone so i was trying to add a java(ant) pr...
# getting-started
a
hey everyone so i was trying to add a java(ant) proj to a kotlin(gradle) proj as a subproj so that i could import it in some Kotlin class? The current file structure is something like this:
Copy code
.
├── build.gradle.kts
├── src
├── settings.gradle.kts
└── JavaProj(ant)
    ├── ant.settings
    └── build.xml
i hope i could make this file stucture clear. but the issue is i could not import the java proj in the kotlin. I think its something realted to including the proj in settings.gradle.kts but searching stackoverflow wasnt enough. Is there something else i ned to do as well while importing another subproj?
r
I don't think gradle will know how to import an ant project out of the box… there might be a gradle plugin that can do it? Edit - I may be wrong, explore https://docs.gradle.org/current/userguide/ant.html
May be easier to build the ant project and include the resulting jar as a file system dependency in gradle.
v
I does know how to do it out of the box. Ant is a first class citizen in Gradle
Imho the best way would be to replace the Ant build by a Gradle build, but importing the Ant build should work just fine.
a
adding the build in build.gradle.kts using ant.importBuild throws an error that
Copy code
Cannot add task 'build' as a task with that name already exists.
i tried registering another task usig tasks.register. But i am still not able to import the classes from JavaProject to some Kotlinclass in kotlin project
oh alright i found Transformer function to actually rename it
but still cannot import it using the import keyword in the kt file
Lets say that there is a Runner.run() metho in the java project that i need to exec in the Kotlin class
v
No, don't import the build in the existing project
You include the project in the settings script, you add an own cradle script for that project and there you import it. Then you also don't have a naming clash
a
i did include that javaproj in the in the settings script. and then tried ant.importBuild. Are you saying that i should change the ant build to the gradle build and then try to import that method?
v
In
JavaProj/build.gradle.kts