KCL Java SDK
- Python3+
- Cargo
- Java 8+
- Maven
make
Generally, you can first add the os-maven-plugin to automatically detect the classifier based on your platform:
<build>
<extensions>
<extension>
<groupId>kr.motd.maven</groupId>
<artifactId>os-maven-plugin</artifactId>
<version>1.7.0</version>
</extension>
</extensions>
</build>
Add the JitPack repository to your build file
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Add the dependency
<dependency>
<groupId>com.github.kcl-lang</groupId>
<artifactId>kcl-java</artifactId>
<version>-SNAPSHOT</version>
</dependency>
For Gradle, you can first add the com.google.osdetector
to automatically detect the classifier based on your platform:
plugins {
id "com.google.osdetector" version "1.7.3"
}
Add it in your root build.gradle at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
Add the dependency
dependencies {
implementation 'com.github.kcl-lang:kcl-java:-SNAPSHOT'
}
import com.kcl.api.API;
import com.kcl.api.Spec.*;
import com.kcl.ast.Program;
import com.kcl.util.JsonUtil;
public class Main {
public void testProgramSymbols() throws Exception {
API api = new API();
LoadPackage_Result result = api.loadPackage(
LoadPackage_Args.newBuilder().setResolveAst(true).setParseArgs(
ParseProgram_Args.newBuilder().addPaths("./src/test_data/schema.k").build())
.build());
String programString = result.getProgram();
Program program = JsonUtil.deserializeProgram(programString);
result.getSymbolsMap().values().forEach(s -> System.out.println(s));
}
}