Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,16 @@ public Generator(String outputDir, String[] libs, boolean throwOnError) throws I

public void writeBindings(String filename) throws IOException {
Binding[] bindings = generateBindings(filename);

List<File> writenFiles = new ArrayList<File>();
for (Binding b : bindings) {
try (PrintStream ps = new PrintStream(b.getFile())) {
ps.append(b.getContent());
if(!writenFiles.contains(b.getFile())) {
writenFiles.add(b.getFile());
try (PrintStream ps = new PrintStream(b.getFile())) {
ps.append(b.getContent());
}
}
else {
throw new IOException("Trying to write already written file. Both files will have the same file name, which will lead to undefined behavior.\nPlease change the name of one of those classes.\n" + b.getFile());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package org.nativescript.staticbindinggenerator;

import java.io.IOException;
import java.util.Arrays;

public class Main {
public static void main(String[] args) {
try {
public static void main(String[] args) throws IOException {
if (args.length < 3) {
throw new IllegalArgumentException("Expects at least three arguments");
}
Expand All @@ -13,8 +13,5 @@ public static void main(String[] args) {
String[] libs = Arrays.copyOfRange(args, 2, args.length);

new Generator(outputDir, libs).writeBindings(inputBindingFilename);
} catch (Exception e) {
e.printStackTrace();
}
}
}
7 changes: 6 additions & 1 deletion build-artifacts/project-template-gradle/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,12 @@ task deleteConfigurations (type: Delete) {
delete "$projectDir/configurations"
}

task deleteGeneratedBindings(type: Delete) {
delete "$projectDir/src/main/java/com/tns/gen"
}

deleteMetadata.dependsOn(":asbg:clean")
deleteFlavors.dependsOn(deleteMetadata)
deleteConfigurations.dependsOn(deleteFlavors)
clean.dependsOn(deleteConfigurations)
deleteGeneratedBindings.dependsOn(deleteConfigurations)
clean.dependsOn(deleteGeneratedBindings)