Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix build directory for classes from Kotlin files #1019

Merged
merged 2 commits into from
Sep 30, 2022

Conversation

volivan239
Copy link
Collaborator

@volivan239 volivan239 commented Sep 27, 2022

Description

Changed the method used to compile classes so that now Kotlin files are compiled to build/classes/kotlin and Java files are compiled to build/classes/java (previously the latter directory was used for both). This avoids duplication with classes generated by default IDEA actions.

Also, refactored some methods to support multiple build directories (important when there are both Java and Kotlin files in project).

Fixes #950

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • Refactoring (typos and non-functional changes)

How Has This Been Tested?

Manual Scenario

Launched plugin on scenario from #950 and several other scenarios with Kotlin files in projects -- everything works normal.

Checklist (remove irrelevant options):

This is the author self-check list

  • The change followed the style guidelines of the UTBot project
  • Self-review of the code is passed
  • The change contains enough commentaries, particularly in hard-to-understand areas
  • New documentation is provided or existed one is altered
  • No new warnings
  • New tests have been added
  • All tests pass locally with my changes

@volivan239 volivan239 force-pushed the volivan239/fix_kotlin_compile_dir branch from 7ba3710 to 68442fb Compare September 27, 2022 16:25
@volivan239 volivan239 force-pushed the volivan239/fix_kotlin_compile_dir branch from 68442fb to 2e0427a Compare September 27, 2022 16:42
@volivan239 volivan239 marked this pull request as ready for review September 27, 2022 21:45
Copy link
Member

@sergeypospelov sergeypospelov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just some minor issues.


init {
if (!isCanceled()) {
checkFrameworkDependencies(dependencyPaths)

logger.trace("Initializing ${this.javaClass.name} with buildDir = $buildDir, classpath = $classpath")
logger.trace("Initializing ${this.javaClass.name} with buildDir = $buildDirs, classpath = $classpath")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
logger.trace("Initializing ${this.javaClass.name} with buildDir = $buildDirs, classpath = $classpath")
logger.trace("Initializing ${this.javaClass.name} with buildDirs = ${buildDirs.joinToString(File.pathSeparator)}, classpath = $classpath")

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed as suggested

@@ -107,7 +107,7 @@ private fun initSoot(buildDir: Path, classpath: String?, jdkInfo: JdkInfo) {
+ if (!classpath.isNullOrEmpty()) File.pathSeparator + "$classpath" else ""
)
set_src_prec(Options.src_prec_only_class)
set_process_dir(listOf("$buildDir"))
set_process_dir(buildDirs.map { "$it" })
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
set_process_dir(buildDirs.map { "$it" })
set_process_dir(buildDirs.map { it.toString() })

it avoids creating unnecessary StringBuilder.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed as suggested

@@ -19,7 +19,7 @@ import org.utbot.engine.overrides.UtOverrideMock
import org.utbot.engine.overrides.collections.AbstractCollection
import org.utbot.engine.overrides.collections.AssociativeArray
import org.utbot.engine.overrides.collections.Collection
import org.utbot.engine.overrides.collections.List
import org.utbot.engine.overrides.collections.List as UtList
Copy link
Member

@sergeypospelov sergeypospelov Sep 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may be confusing, because we already have UtList. Maybe use fqn like org.utbot.engine.overrides.collections.List?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replaced all overrides with FQN

@volivan239 volivan239 force-pushed the volivan239/fix_kotlin_compile_dir branch from 2e0427a to afd95ca Compare September 28, 2022 13:02
@volivan239 volivan239 force-pushed the volivan239/fix_kotlin_compile_dir branch from afd95ca to 3d7829e Compare September 30, 2022 09:51
@volivan239 volivan239 enabled auto-merge (squash) September 30, 2022 09:51
@volivan239 volivan239 merged commit edf6c5a into main Sep 30, 2022
@volivan239 volivan239 deleted the volivan239/fix_kotlin_compile_dir branch September 30, 2022 10:33
AbdullinAM pushed a commit to AbdullinAM/UTBotJava that referenced this pull request Oct 17, 2022
AbdullinAM pushed a commit to AbdullinAM/UTBotJava that referenced this pull request Oct 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"Entry <...> is a duplicate" error after launching test generated for Kotlin
3 participants