Skip to content

Commit

Permalink
small refactors
Browse files Browse the repository at this point in the history
  • Loading branch information
harrel56 committed Sep 30, 2023
1 parent 442f557 commit 8c70fbc
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 16 deletions.
3 changes: 0 additions & 3 deletions examples/simple/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ plugins {
id 'dev.harrel.java2ts' version '0.1.0'
}

group 'dev.example'
version '0.1'

repositories {
mavenCentral()
}
Expand Down
2 changes: 1 addition & 1 deletion examples/simple/src/main/java/Example.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
public class Example {
public String[] hello2;
public String[] hello233;
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class MainTest {
void main() throws IOException {
TsGenerator gen = new TsGenerator();
// gen.setSupportedPredicate(c -> !c.getPackageName().contains("java.reflection"));
gen.registerType(List.class);
gen.registerType(SimpleClass.class);
System.out.println(gen.getAllDeclarations());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,10 @@

import java.io.File;
import java.io.IOException;
import java.io.Serializable;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.nio.file.Files;
import java.util.function.Function;
import java.util.function.Predicate;

interface SerializableFunction<T, R> extends Function<T, R>, Serializable {
}

interface SerializablePredicate<T> extends Predicate<T>, Serializable {
}

public abstract class GenerateTsDeclarationsTask extends DefaultTask {

Expand Down Expand Up @@ -70,7 +61,9 @@ public void generate() {

private TsGenerator createTsGenerator() {
TsGenerator gen = new TsGenerator();
gen.setSortingEnabled(Boolean.TRUE.equals(getSorting().getOrElse(true)));
if (getSorting().isPresent()) {
gen.setSortingEnabled(getSorting().get());
}
if (getSupportedPredicate().isPresent()) {
gen.setSupportedPredicate(getSupportedPredicate().get());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public void apply(Project project) {
var extension = project.getExtensions().create("generateTsDeclarations", GenerateExtension.class);

project.getTasks().register("generateTsDeclarations", GenerateTsDeclarationsTask.class, task -> {
SourceSet sourceSet = extension.getSourceSet().orElse(getDefaultSourceSet(project)).get();
SourceSet sourceSet = extension.getSourceSet().convention(getDefaultSourceSet(project)).get();

task.dependsOn(sourceSet.getCompileJavaTaskName());
task.getSourceFiles().set(sourceSet.getRuntimeClasspath().plus(sourceSet.getOutput().getClassesDirs()).getFiles());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package dev.harrel.java2ts;

import java.io.Serializable;
import java.util.function.Function;

public interface SerializableFunction<T, R> extends Function<T, R>, Serializable {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package dev.harrel.java2ts;

import java.io.Serializable;
import java.util.function.Predicate;

public interface SerializablePredicate<T> extends Predicate<T>, Serializable {
}

0 comments on commit 8c70fbc

Please sign in to comment.