-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The commit updates the version to 242 in `.github/workflows/publish-snapshot.yml.disabled` and `build.gradle.kts` files. Additionally, new IDE patch policy has been implemented in `.github/workflows/test.yml`, allowing continual tests even on failures. For this, multiple environment variables have been defined and an if clause is introduced to check failure conditions before patching and re-running tests. Modifications are also made to `SourceSetModel.kt` to handle dependencies slightly differently. The file `kmp-modifier/src/test/kotlin/com/jetbrains/packageSearch/mppDependencyUpdater/intellijStuff/SdkTestCase.kt` has been largely commented out.
- Loading branch information
Showing
15 changed files
with
664 additions
and
382 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
package com.jetbrains.packagesearch.plugin.tests.scripts | ||
|
||
import java.nio.file.Path | ||
import java.nio.file.Paths | ||
import javax.xml.parsers.DocumentBuilderFactory | ||
import javax.xml.transform.OutputKeys | ||
import javax.xml.transform.TransformerFactory | ||
import javax.xml.transform.dom.DOMSource | ||
import javax.xml.transform.stream.StreamResult | ||
import kotlin.io.path.exists | ||
import kotlin.io.path.listDirectoryEntries | ||
import org.w3c.dom.Document | ||
import org.w3c.dom.Element | ||
|
||
private val domFileName="builtinRegistry" | ||
|
||
fun main(){ | ||
scoutRegistryFiles().forEach { | ||
println("Patching file: $it") | ||
patchKotlinGradlePlugin(it) | ||
} | ||
} | ||
|
||
// WARNING: USE THIS FUNCTION WITH CAUTION AND ONLY FOR TESTS PURPOSES | ||
internal fun scoutRegistryFiles(): List<Path> { | ||
println("Scouting registry files") | ||
val userDir = Path.of(System.getProperty("user.home")) | ||
println("current directory: $userDir") | ||
println("contains: ${userDir.listDirectoryEntries()}") | ||
println ("Scouting for gradle ide caches") | ||
val gradleDir= Path.of(userDir.toString(), ".gradle") | ||
println("gradle directory exists: ${gradleDir.exists()}") | ||
val cacheDir= Paths.get(gradleDir.toString(), "caches", "modules-2", "files-2.1", "com.jetbrains.intellij.idea", "ideaIC") | ||
println("idea cache directory exists: ${cacheDir.exists()}") | ||
|
||
//scout for the registry file | ||
val configsFiles= buildList { | ||
cacheDir.toFile().walk().forEach { | ||
if (it.name.contains(domFileName) && it.extension.lowercase().endsWith("xml")) { | ||
add(it.toPath()) | ||
} | ||
} | ||
} | ||
|
||
println("Found ${configsFiles.size} registry files") | ||
configsFiles.forEach { println(it) } | ||
|
||
return configsFiles | ||
} | ||
|
||
internal fun patchKotlinGradlePlugin(xmlPath: Path) { | ||
if (!xmlPath.exists()) { | ||
error("can not find XML file to patch: $xmlPath") | ||
} | ||
|
||
val xmlFile = xmlPath.toFile() | ||
val documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder() | ||
val document: Document = documentBuilder.parse(xmlFile) | ||
|
||
// Create the new plugin element with its attributes | ||
val pluginElement: Element = document.createElement("plugin") | ||
pluginElement.setAttribute("directoryName", "Kotlin") | ||
pluginElement.setAttribute("id", "org.jetbrains.kotlin") | ||
|
||
// Create the dependencies element | ||
val dependenciesElement: Element = document.createElement("dependencies") | ||
|
||
// List of dependency values | ||
val dependencyValues = listOf( | ||
"com.intellij.modules.platform", | ||
"com.intellij.modules.java", | ||
"com.intellij.modules.java-capable", | ||
"com.intellij.java" | ||
) | ||
|
||
// Add each dependency to the dependencies element | ||
for (dependencyValue in dependencyValues) { | ||
val dependencyElement: Element = document.createElement("dependency") | ||
dependencyElement.appendChild(document.createTextNode(dependencyValue)) | ||
dependenciesElement.appendChild(dependencyElement) | ||
} | ||
|
||
// Append the dependencies element to the plugin element | ||
pluginElement.appendChild(dependenciesElement) | ||
|
||
// Append the plugin element to the root element | ||
document.documentElement.appendChild(pluginElement) | ||
|
||
// Save the updated document back to the file | ||
val transformerFactory = TransformerFactory.newInstance() | ||
val transformer = transformerFactory.newTransformer() | ||
transformer.setOutputProperty(OutputKeys.INDENT, "yes") | ||
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2") | ||
val source = DOMSource(document) | ||
val result = StreamResult(xmlFile) | ||
transformer.transform(source, result) | ||
|
||
println("XML file updated successfully.") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import java.nio.file.Path | ||
import java.nio.file.Paths | ||
import javax.xml.parsers.DocumentBuilderFactory | ||
import javax.xml.transform.OutputKeys | ||
import javax.xml.transform.TransformerFactory | ||
import javax.xml.transform.dom.DOMSource | ||
import javax.xml.transform.stream.StreamResult | ||
import kotlin.io.path.exists | ||
import kotlin.io.path.listDirectoryEntries | ||
import org.w3c.dom.Document | ||
import org.w3c.dom.Element | ||
|
||
val domFileName = "builtinRegistry" | ||
|
||
println("Scouting registry files") | ||
val userDir = Path.of(System.getProperty("user.home")) | ||
println("current directory: $userDir") | ||
println("contains: ${userDir.listDirectoryEntries()}") | ||
println ("Scouting for gradle ide caches") | ||
val gradleDir = Path.of(userDir.toString(), ".gradle") | ||
println("gradle directory exists: ${gradleDir.exists()}") | ||
val cacheDir = | ||
Paths.get(gradleDir.toString(), "caches", "modules-2", "files-2.1", "com.jetbrains.intellij.idea", "ideaIC") | ||
println("idea cache directory exists: ${cacheDir.exists()}") | ||
|
||
//scout for the registry file | ||
val configsFiles = buildList { | ||
cacheDir.toFile().walk().forEach { | ||
if (it.name.contains(domFileName) && it.extension.lowercase().endsWith("xml")) { | ||
add(it.toPath()) | ||
} | ||
} | ||
} | ||
|
||
println("Found ${configsFiles.size} registry files") | ||
configsFiles.forEach { | ||
xmlPath -> | ||
if (!xmlPath.exists()) { | ||
error("can not find XML file to patch: $xmlPath") | ||
} | ||
|
||
val xmlFile = xmlPath.toFile() | ||
val documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder() | ||
val document: Document = documentBuilder.parse(xmlFile) | ||
|
||
// Create the new plugin element with its attributes | ||
val pluginElement: Element = document.createElement("plugin") | ||
pluginElement.setAttribute("directoryName", "Kotlin") | ||
pluginElement.setAttribute("id", "org.jetbrains.kotlin") | ||
|
||
// Create the dependencies element | ||
val dependenciesElement: Element = document.createElement("dependencies") | ||
|
||
// List of dependency values | ||
val dependencyValues = listOf( | ||
"com.intellij.modules.platform", | ||
"com.intellij.modules.java", | ||
"com.intellij.modules.java-capable", | ||
"com.intellij.java" | ||
) | ||
|
||
// Add each dependency to the dependencies element | ||
for (dependencyValue in dependencyValues) { | ||
val dependencyElement: Element = document.createElement("dependency") | ||
dependencyElement.appendChild(document.createTextNode(dependencyValue)) | ||
dependenciesElement.appendChild(dependencyElement) | ||
} | ||
|
||
// Append the dependencies element to the plugin element | ||
pluginElement.appendChild(dependenciesElement) | ||
|
||
// Append the plugin element to the root element | ||
document.documentElement.appendChild(pluginElement) | ||
|
||
// Save the updated document back to the file | ||
val transformerFactory = TransformerFactory.newInstance() | ||
val transformer = transformerFactory.newTransformer() | ||
transformer.setOutputProperty(OutputKeys.INDENT, "yes") | ||
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2") | ||
val source = DOMSource(document) | ||
val result = StreamResult(xmlFile) | ||
transformer.transform(source, result) | ||
|
||
println("XML file updated successfully.") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.