Skip to content

Commit

Permalink
chore: Update documentation
Browse files Browse the repository at this point in the history
Update the documentation for plugin interface.
  • Loading branch information
Chrylo committed Feb 6, 2024
1 parent 3227633 commit c35e53e
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 176 deletions.
1 change: 0 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ val dependentCompositeTasks = setOf(
"setSnapshotVersion",
"setReleaseVersion",
"publishToMavenLocal",
"publishAllPublicationsToOSSRHSnapshotRepository",
"publishAllPublicationsToOSSRHReleaseRepository",
)

Expand Down
2 changes: 1 addition & 1 deletion buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Lice nse is distributed on an "AS IS" BASIS,
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
Expand Down
13 changes: 4 additions & 9 deletions docs/QUICKSTART.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,15 +163,10 @@ dependencies {
ksp("org.eclipse.kuksa:vss-processor:<VERSION>")
}
// Copies the given specification file to the KSP processor
tasks.register<ProvideVssDefinitionTask>("ProvideVssDefinition") {
val vssDefinitionFilePath = "$projectDir/src/main/assets/<VSS_FILE.yml>"
val regularFile = RegularFile { File(vssDefinitionFilePath) }
vssDefinitionFile.add(regularFile)
}
tasks.withType<KspTask> {
dependsOn(tasks.withType<ProvideVssDefinitionTask>())
// Optional - See plugin documentation. Files inside the main assets are used automatically.
vssProcessor {
searchPath = "$projectDir/src/main/assets"
fileName = "vss_rel_4.0.yaml"
}
```

Expand Down
2 changes: 0 additions & 2 deletions kuksa-sdk/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -122,5 +122,3 @@ protobuf {
}
}
}


2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pluginManagement {

plugins {
id("com.google.devtools.ksp") version "1.9.0-1.0.11"
id("org.eclipse.kuksa.vss-processor-plugin") version "0.1.3"
id("org.eclipse.kuksa.vss-processor-plugin") // Always take the newest version since it's locally included
kotlin("jvm") version "1.9.0-1.0.11"
kotlin("plugin.serialization") version "1.9.0"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,10 @@ package org.eclipse.kuksa.vsscore.annotation
* id("org.eclipse.kuksa.vss-processor-plugin") version "<VERSION>"
* }
*
* tasks.register<ProvideVssDefinitionTask>("ProvideVssDefinition") {
* val vssDefinitionFilePath = "$projectDir/src/main/assets/vss_rel_4.0.yaml"
* val regularFile = RegularFile { File(vssDefinitionFilePath) }
* vssDefinitionFile.add(regularFile)
* }
*
* tasks.withType<KspTask> {
* dependsOn(tasks.withType<ProvideVssDefinitionTask>())
* // Optional - See plugin documentation. Files inside the main assets are used automatically.
* vssProcessor {
* searchPath = "$projectDir/src/main/assets"
* fileName = "vss_rel_4.0.yaml"
* }
* ```
*
Expand Down
12 changes: 2 additions & 10 deletions vss-processor-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ plugins {
alias(libs.plugins.pluginPublishing)
signing
`kotlin-dsl`
// publish
version
}

Expand Down Expand Up @@ -56,15 +55,8 @@ afterEvaluate {
password = System.getenv("ORG_OSSRH_PASSWORD")
}
}
maven {
name = "OSSRHSnapshot"

url = uri("https://oss.sonatype.org/content/repositories/snapshots/")
credentials {
username = System.getenv("ORG_OSSRH_USERNAME")
password = System.getenv("ORG_OSSRH_PASSWORD")
}
}
// Snapshot are disabled for Plugins since the plugin marker has issues finding the correct jar with the
// automatic timestamps / build number being added as a postfix to the files.
}
publications {
getByName<MavenPublication>("pluginMaven") {
Expand Down
114 changes: 0 additions & 114 deletions vss-processor-plugin/buildSrc/src/main/kotlin/publish.gradle.kts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,12 @@ internal constructor(objectFactory: ObjectFactory) {
val fileName: Property<String> = objectFactory.property(String::class.java).convention("")
}

private val fileSeparator = File.separator

/**
* This Plugin searches for compatible specification files and copies them into an input folder for the
* KSP VSS Processor. This is necessary because the Symbol Processor does not have access to the android assets folder.
* The default search path is the main assets folder.
*
*/
class VssProcessorPlugin : Plugin<Project> {
override fun apply(project: Project) {
Expand All @@ -64,21 +65,22 @@ class VssProcessorPlugin : Plugin<Project> {
val compatibleFiles = findFiles(
directory = searchDirectory,
fileName = extension.fileName.get(),
validExtensions = compatibleExtensions
validExtensions = compatibleExtensions,
)

val provideVssDefinitionTask = project.tasks.register<ProvideVssDefinitionTask>("ProvideVssDefinition") {
val provideVssDefinitionTask = project.tasks.register<ProvideVssDefinitionTask>(PROVIDE_VSS_DEFINITION_TASK) {
compatibleFiles.forEach { definitionFile ->
val regularFile = RegularFile { definitionFile }
vssDefinitionFiles.add(regularFile)
}
}

project.tasks.getByName("preBuild").finalizedBy(
provideVssDefinitionTask.get()
provideVssDefinitionTask.get(),
)
}

@Suppress("SameParameterValue")
private fun findFiles(
directory: String,
fileName: String = "",
Expand All @@ -98,42 +100,22 @@ class VssProcessorPlugin : Plugin<Project> {

companion object {
private const val EXTENSION_NAME = "vssProcessor"
private const val PROVIDE_VSS_DEFINITION_TASK = "ProvideVssDefinition"

private val compatibleExtensions = setOf("yaml")
private val fileSeparator = File.separator
private val mainAssetsDirectory = "src$fileSeparator" + "main$fileSeparator" + "assets"
}
}

/**
* This task takes a collection of files
*/
abstract class ProvideVssDefinitionTask : DefaultTask() {

@get:InputFiles
abstract val vssDefinitionFiles: ListProperty<RegularFile>

@TaskAction
fun provideFile() {
// val buildDirPath = project.buildDir.absolutePath
// val mainAssets = "${project.projectDir}$fileSeparator$mainAssetsDirectory"
// val mainAssetsFolder = File(mainAssets)

// mainAssetsFolder
// .walk()
// .filter { compatibleExtensions.contains(it.extension) }
// .forEach { vssDefinitionInputFile ->
// val vssDefinitionBuildFile = File(
// "$buildDirPath$fileSeparator" +
// "$KSP_INPUT_BUILD_DIRECTORY$fileSeparator" +
// vssDefinitionInputFile.name,
// )
//
// println(
// "Found VSS definition input file: ${vssDefinitionInputFile.name}, " +
// "copying to: $vssDefinitionBuildFile",
// )
//
// vssDefinitionInputFile.copyTo(vssDefinitionBuildFile, true)
// }

val buildDirPath = project.buildDir.absolutePath
vssDefinitionFiles.get().forEach { file ->
val vssDefinitionInputFile = file.asFile
Expand All @@ -152,7 +134,5 @@ abstract class ProvideVssDefinitionTask : DefaultTask() {

companion object {
private const val KSP_INPUT_BUILD_DIRECTORY = "kspInput"

private val fileSeparator = File.separator
}
}

0 comments on commit c35e53e

Please sign in to comment.