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
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,9 @@ Rename classes.jar if necessary
```shell
java -jar build\libs\dts-generator.jar -input classes.jar dependency-of-classes-jar.jar
```

## Support libraries
In the [lib](lib) folder there are android support libraries jars which are get from the following git repos:
* [android-support-v4](https://github.com/dandar3/android-support-v4/tree/master/libs)
* [android-support-v7-appcompat](https://github.com/dandar3/android-support-v7-appcompat/tree/master/libs)
* [android-support-design](https://github.com/dandar3/android-support-design/tree/master/libs)
14 changes: 9 additions & 5 deletions dts-generator/src/main/java/com/telerik/dts/DtsApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ public class DtsApi {
private Map<String, String> aliasedTypes;
private String[] namespaceParts;
private int indent = 0;
private boolean writeMultipleFiles;

public DtsApi() {
public DtsApi(boolean writeMultipleFiles) {
this.writeMultipleFiles = writeMultipleFiles;
this.indent = 0;

overrideFieldComparator();
Expand Down Expand Up @@ -157,10 +159,12 @@ public String generateDtsContent(List<JavaClass> javaClasses) {
String[] refs = references.toArray(new String[references.size()]);
Arrays.sort(refs);

for (String r : refs) {
sbHeaders.append("/// <reference path=\"./");
sbHeaders.append(r);
sbHeaders.appendln(".d.ts\" />");
if(this.writeMultipleFiles) {
for (String r : refs) {
sbHeaders.append("/// <reference path=\"./");
sbHeaders.append(r);
sbHeaders.appendln(".d.ts\" />");
}
}
}

Expand Down
16 changes: 5 additions & 11 deletions dts-generator/src/main/java/com/telerik/dts/FileWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public class FileWriter {
private boolean writeMultipleFiles;
private PrintStream ps;
private File outDir;
private boolean isFirstRun = true;

public FileWriter(File outDir, boolean writeMultipleFiles) {
this.writeMultipleFiles = writeMultipleFiles;
Expand All @@ -37,12 +36,6 @@ public void write(String content, String fileName) {
String outFile = this.outDir.getAbsolutePath() + File.separator + this.defaultDtsFileName + ".d.ts";
this.ps = new PrintStream(new FileOutputStream(outFile, /*append*/true));

// add helpers reference to the top of the file
if(this.isFirstRun) {
ps.println("/// <reference path=\"./_helpers.d.ts\" />");
this.isFirstRun = false;
}

this.ps.print(content);
this.ps.println();
}
Expand All @@ -58,11 +51,12 @@ public void write(String content, String fileName) {

public void writeHelperTypings(String content, boolean append) {
try {
String outFile = this.outDir.getAbsolutePath() + File.separator + "_helpers.d.ts";
this.ps = new PrintStream(new FileOutputStream(outFile, append));
String outFile = this.outDir.getAbsolutePath() + File.separator +
(this.writeMultipleFiles ? "_helpers.d.ts": (this.defaultDtsFileName + ".d.ts"));
this.ps = new PrintStream(new FileOutputStream(outFile, append));

this.ps.print(content);
this.ps.println();
this.ps.print(content);
this.ps.println();
} catch (FileNotFoundException e) {
e.printStackTrace();
}
Expand Down
2 changes: 1 addition & 1 deletion dts-generator/src/main/java/com/telerik/dts/Generator.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class Generator {
public void start(InputParameters inputParameters) throws IOException {
outFolder = inputParameters.getOutputDir();
this.fw = new FileWriter(inputParameters.getOutputDir(), inputParameters.isGenerateMultipleFiles());
this.dtsApi = new DtsApi();
this.dtsApi = new DtsApi(inputParameters.isGenerateMultipleFiles());

loadJavaClasses(inputParameters.getInputJars());
ClassRepo.sortCachedProviders();
Expand Down
Binary file not shown.
Binary file added libs/android-support/27.0.0/android-support-v4.jar
Binary file not shown.
Binary file not shown.