Skip to content

Commit

Permalink
using sbt project name as the artifact name in IdeaConfigBuilder (as …
Browse files Browse the repository at this point in the history
…it is done for IdeaArtifactXmlBuilder)
  • Loading branch information
azdrojowa123 committed Oct 8, 2024
1 parent 0c9675a commit e7fb0d9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ object GenerateIdeaRunConfigurations extends SbtIdeaTask[Unit] {
PluginLogger.bind(new SbtPluginLogger(streams.value))
val buildInfo = sbtidea.Keys.intellijBuildInfo.in(ThisBuild).value
val vmOptions = intellijVMOptions.value.copy(debug = false)
val configName = name.value
val dotIdeaFolder = baseDirectory.in(ThisBuild).value / ".idea"
val sbtRunEnv = envVars.value
val sbtTestEnv = envVars.in(Test).value
Expand All @@ -45,13 +44,8 @@ object GenerateIdeaRunConfigurations extends SbtIdeaTask[Unit] {
.map(x => if (x.ideaRunEnv.isEmpty) x.copy(ideaRunEnv = sbtRunEnv) else x)
.map(x => if (x.ideaTestEnv.isEmpty) x.copy(ideaTestEnv = sbtTestEnv) else x)
.get
val projectName = name.value
val moduleName =
if (hasProdTestSeparationEnabled) s"$projectName.main"
else projectName
val configBuilder = new IdeaConfigBuilder(
moduleName = moduleName,
configName = configName,
projectName = name.value,
intellijVMOptions = vmOptions,
dataDir = intellijPluginDirectory.value,
intellijBaseDir = intellijBaseDirectory.in(ThisBuild).value,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package org.jetbrains.sbtidea.tasks

import coursier.{Dependency, Fetch, Module, ModuleName, Organization}
import org.jetbrains.sbtidea.Keys.IdeaConfigBuildingOptions
import org.jetbrains.sbtidea.packaging.hasProdTestSeparationEnabled
import org.jetbrains.sbtidea.productInfo.ProductInfoExtraDataProvider
import org.jetbrains.sbtidea.runIdea.{IntellijAwareRunner, IntellijVMOptions}
import org.jetbrains.sbtidea.tasks.IdeaConfigBuilder.{computeJupiterRuntimeDependencies, pathPattern, pluginsPattern}
Expand All @@ -13,15 +14,12 @@ import java.io.File
import java.nio.file.{Path, Paths}
import java.util.regex.Pattern
import scala.annotation.tailrec
import scala.collection.mutable
import scala.collection.mutable.ArrayBuffer

/**
* @param testPluginRoots contains only those plugins which are listed in the project IntelliJ plugin dependencies and their transitive dependencies
*/
class IdeaConfigBuilder(
moduleName: String,
configName: String,
projectName: String,
intellijVMOptions: IntellijVMOptions,
dataDir: File,
intellijBaseDir: File,
Expand All @@ -37,10 +35,14 @@ class IdeaConfigBuilder(

private val IDEA_ROOT_KEY = "idea.installation.dir"

private val moduleName: String =
if (hasProdTestSeparationEnabled) s"$projectName.main"
else projectName

def build(): Unit = {
if (options.generateDefaultRunConfig) {
val content = buildRunConfigurationXML(configName, intellijVMOptions)
writeToFile(runConfigDir / s"$configName.xml", content)
val content = buildRunConfigurationXML(projectName, intellijVMOptions)
writeToFile(runConfigDir / s"$projectName.xml", content)
}
if (options.generateJUnitTemplate)
writeToFile(runConfigDir / "_template__of_JUnit.xml", buildJUnitTemplate)
Expand Down Expand Up @@ -190,7 +192,7 @@ class IdeaConfigBuilder(
| <method v="2">
| <option name="Make" enabled="true" />
| <option name="BuildArtifacts" enabled="true">
| <artifact name="$moduleName" />
| <artifact name="$projectName" />
| </option>
| </method>
| </configuration>
Expand Down Expand Up @@ -259,7 +261,7 @@ class IdeaConfigBuilder(
| <method v="2">
| <option name="Make" enabled="true" />
| <option name="BuildArtifacts" enabled="true">
| <artifact name="$moduleName" />
| <artifact name="$projectName" />
| </option>
| </method>
| </configuration>
Expand Down

0 comments on commit e7fb0d9

Please sign in to comment.