An open API service indexing awesome lists of open source software.

https://github.com/stackgenhq/flatgraph-codegen-gradle


https://github.com/stackgenhq/flatgraph-codegen-gradle

Last synced: 6 months ago
JSON representation

Awesome Lists containing this project

README

          

# Flatgraph Codegen Gradle

A Gradle version of the Flatgraph codegen sbt plugin

## Usage

Configure the task in your `build.gradle.kts`, eg:
```kotlin
tasks.named("generateDomainClasses") {
classWithSchema = "CpgExtSchema$"
fieldName = "instance"
outputDirectory = file("build/generated/flatgraph/main/scala")
}
```

...where your `src/main/scala` directory contains the `CpgExtSchema` object with the `instance` field containing any
desired schema extensions.
```scala
import flatgraph.schema.SchemaBuilder
import flatgraph.schema.Property.ValueType
import io.shiftleft.codepropertygraph.schema.CpgSchema

class CpgExtSchema(builder: SchemaBuilder, cpgSchema: CpgSchema) {

// Add node types, edge types, and properties here

val myProperty = builder
.addProperty(name = "MYPROPERTY", valueType = ValueType.String)
.mandatory("")

val myNodeType = builder
.addNodeType("MYNODETYPE")
.addProperty(myProperty)

}

object CpgExtSchema {
val builder = new SchemaBuilder(domainShortName = "Cpg", basePackage = "flatgraph.generated")
val cpgSchema = new CpgSchema(builder)
val cpgExtSchema = new CpgExtSchema(builder, cpgSchema)
val instance = builder.build
}
```

See also [example](example/build.gradle.kts)

## Contributing

Please read [CONTRIBUTING.md](.github/CONTRIBUTING.md) for details on contributing and our code of conduct.