With the sbt-idea plugin, I can generate idea project for a sbt project.
But what if I want it to be a javafx project? Which should have the "JavaFx" artifact. I can add it manually in idea once, but I don't want to do it every time.
If I add the "JavaFx" artifact, there will be one new file created in the .idea
directory:
.idea
artifacts
mypro.xml
with the content:
<component name="ArtifactManager">
<artifact type="javafx" name="mypro">
<output-path>$PROJECT_DIR$/target/idea_output/artifacts/mypro</output-path>
<root id="root">
<element id="archive" name="mypro.jar">
<element id="module-output" name="mypro" />
</element>
</root>
</artifact>
</component>
Is it possible to let sbt generate this file when run gen-idea
?
I don't think you can do it easily with the sbt-idea plugin. What you could do though is define your own command gen-idea-fx
, which would run the original gen-idea
and then generate the file you want.
val generateIdeaFx: State => State = { state =>
val newState = Command.process("gen-idea", state)
val extracted: Extracted = Project.extract(newState)
import extracted._
val projectName: String = (name in currentRef get structure.data).get
val artifactName: String = (artifact in (currentRef, Compile, packageBin) get structure.data).map { a =>
a.name + a.extension
}.get
val artifactXml =
<component name="ArtifactManager">
<artifact type="javafx" name={projectName}>
<output-path>$PROJECT_DIR$/target/idea_output/artifacts/{projectName}</output-path>
<element id="root">
<element id="archive" name={artifactName} />
</element>
</artifact>
</component>
val outputFile = (baseDirectory in currentRef get structure.data).get / ".idea" / "artifacts" / s"$projectName.xml"
IO.write(outputFile, artifactXml.mkString)
newState
}
val genIdeaFx = Command.command("gen-idea-fx")(generateIdeaFx)
commands += genIdeaFx
Now you can generate Idea project by calling gen-idea-fx
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.