Skip to content

Commit d5a0476

Browse files
author
Federico Fissore
committed
Installing tools from packager (eg: arduino) in packager folder, thus avoiding
tools duplication and disk space wasting. Fixes #4193
1 parent a1e223a commit d5a0476

24 files changed

+55
-45
lines changed

.classpath

+4-4
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121
<classpathentry kind="lib" path="app/lib/jssc-2.8.0.jar"/>
2222
<classpathentry kind="lib" path="app/lib/bcpg-jdk15on-152.jar"/>
2323
<classpathentry kind="lib" path="app/lib/bcprov-jdk15on-152.jar"/>
24-
<classpathentry kind="lib" path="app/lib/jackson-core-2.2.3.jar"/>
25-
<classpathentry kind="lib" path="app/lib/jackson-databind-2.2.3.jar"/>
26-
<classpathentry kind="lib" path="app/lib/jackson-module-mrbean-2.2.3.jar"/>
27-
<classpathentry kind="lib" path="app/lib/jackson-annotations-2.2.3.jar"/>
24+
<classpathentry kind="lib" path="app/lib/jackson-core-2.6.3.jar"/>
25+
<classpathentry kind="lib" path="app/lib/jackson-databind-2.6.3.jar"/>
26+
<classpathentry kind="lib" path="app/lib/jackson-module-mrbean-2.6.3.jar"/>
27+
<classpathentry kind="lib" path="app/lib/jackson-annotations-2.6.3.jar"/>
2828
<classpathentry kind="lib" path="app/lib/commons-compress-1.8.jar"/>
2929
<classpathentry combineaccessrules="false" kind="src" path="/arduino-core"/>
3030
<classpathentry kind="output" path="app/bin"/>

app/.classpath

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
<classpathentry kind="lib" path="lib/commons-httpclient-3.1.jar"/>
1313
<classpathentry kind="lib" path="lib/commons-logging-1.0.4.jar"/>
1414
<classpathentry kind="lib" path="lib/commons-net-3.3.jar"/>
15-
<classpathentry kind="lib" path="lib/jackson-annotations-2.2.3.jar"/>
16-
<classpathentry kind="lib" path="lib/jackson-core-2.2.3.jar"/>
17-
<classpathentry kind="lib" path="lib/jackson-databind-2.2.3.jar"/>
18-
<classpathentry kind="lib" path="lib/jackson-module-mrbean-2.2.3.jar"/>
15+
<classpathentry kind="lib" path="lib/jackson-annotations-2.6.3.jar"/>
16+
<classpathentry kind="lib" path="lib/jackson-core-2.6.3.jar"/>
17+
<classpathentry kind="lib" path="lib/jackson-databind-2.6.3.jar"/>
18+
<classpathentry kind="lib" path="lib/jackson-module-mrbean-2.6.3.jar"/>
1919
<classpathentry kind="lib" path="lib/jmdns-3.4.1.jar"/>
2020
<classpathentry kind="lib" path="lib/jsch-0.1.50.jar"/>
2121
<classpathentry kind="lib" path="lib/jssc-2.8.0.jar"/>

app/lib/jackson-annotations-2.2.3.jar

-32.7 KB
Binary file not shown.

app/lib/jackson-annotations-2.6.3.jar

45.9 KB
Binary file not shown.

app/lib/jackson-core-2.2.3.jar

-188 KB
Binary file not shown.

app/lib/jackson-core-2.6.3.jar

253 KB
Binary file not shown.

app/lib/jackson-databind-2.2.3.jar

-846 KB
Binary file not shown.

app/lib/jackson-databind-2.6.3.jar

1.12 MB
Binary file not shown.
-67.3 KB
Binary file not shown.
78 KB
Binary file not shown.

arduino-core/.classpath

+8-8
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,21 @@
1313
<classpathentry kind="lib" path="../app/lib/commons-compress-1.8.jar"/>
1414
<classpathentry kind="lib" path="../app/lib/commons-exec-1.1.jar"/>
1515
<classpathentry kind="lib" path="../app/lib/commons-httpclient-3.1.jar"/>
16-
<classpathentry kind="lib" path="../app/lib/jackson-annotations-2.2.3.jar"/>
17-
<classpathentry kind="lib" path="../app/lib/jackson-core-2.2.3.jar"/>
18-
<classpathentry kind="lib" path="../app/lib/jackson-databind-2.2.3.jar"/>
19-
<classpathentry kind="lib" path="../app/lib/jackson-module-mrbean-2.2.3.jar"/>
16+
<classpathentry kind="lib" path="../app/lib/jackson-annotations-2.6.3.jar"/>
17+
<classpathentry kind="lib" path="../app/lib/jackson-core-2.6.3.jar"/>
18+
<classpathentry kind="lib" path="../app/lib/jackson-databind-2.6.3.jar"/>
19+
<classpathentry kind="lib" path="../app/lib/jackson-module-mrbean-2.6.3.jar"/>
2020
<classpathentry kind="lib" path="../app/lib/bcpg-jdk15on-152.jar"/>
2121
<classpathentry kind="lib" path="../app/lib/bcprov-jdk15on-152.jar"/>
2222
<classpathentry kind="lib" path="lib/bcpg-jdk15on-152.jar"/>
2323
<classpathentry kind="lib" path="lib/bcprov-jdk15on-152.jar"/>
2424
<classpathentry kind="lib" path="lib/commons-codec-1.7.jar"/>
2525
<classpathentry kind="lib" path="lib/commons-compress-1.8.jar"/>
2626
<classpathentry kind="lib" path="lib/commons-lang3-3.3.2.jar"/>
27-
<classpathentry kind="lib" path="lib/jackson-annotations-2.2.3.jar"/>
28-
<classpathentry kind="lib" path="lib/jackson-core-2.2.3.jar"/>
29-
<classpathentry kind="lib" path="lib/jackson-databind-2.2.3.jar"/>
30-
<classpathentry kind="lib" path="lib/jackson-module-mrbean-2.2.3.jar"/>
27+
<classpathentry kind="lib" path="lib/jackson-annotations-2.6.3.jar"/>
28+
<classpathentry kind="lib" path="lib/jackson-core-2.6.3.jar"/>
29+
<classpathentry kind="lib" path="lib/jackson-databind-2.6.3.jar"/>
30+
<classpathentry kind="lib" path="lib/jackson-module-mrbean-2.6.3.jar"/>
3131
<classpathentry kind="lib" path="lib/java-semver-0.8.0.jar"/>
3232
<classpathentry kind="lib" path="lib/jna-4.1.0.jar"/>
3333
<classpathentry kind="lib" path="lib/jna-platform-4.1.0.jar"/>
-32.7 KB
Binary file not shown.
45.9 KB
Binary file not shown.
-188 KB
Binary file not shown.
253 KB
Binary file not shown.
-846 KB
Binary file not shown.
1.12 MB
Binary file not shown.
-67.3 KB
Binary file not shown.
Binary file not shown.

arduino-core/src/cc/arduino/contributions/packages/ContributedPlatform.java

+12-11
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,9 @@
3030
package cc.arduino.contributions.packages;
3131

3232
import cc.arduino.contributions.DownloadableContribution;
33+
import com.fasterxml.jackson.annotation.JsonIgnore;
3334

34-
import java.util.ArrayList;
35-
import java.util.Collection;
36-
import java.util.LinkedList;
37-
import java.util.List;
35+
import java.util.*;
3836

3937
public abstract class ContributedPlatform extends DownloadableContribution {
4038

@@ -54,18 +52,21 @@ public abstract class ContributedPlatform extends DownloadableContribution {
5452

5553
public abstract ContributedHelp getHelp();
5654

57-
private List<ContributedTool> resolvedTools;
55+
private Map<ContributedToolReference, ContributedTool> resolvedToolReferences;
56+
5857
private ContributedPackage parentPackage;
5958

6059
public List<ContributedTool> getResolvedTools() {
61-
if (resolvedTools == null) {
62-
return null;
63-
}
64-
return new LinkedList<>(resolvedTools);
60+
return new LinkedList<>(resolvedToolReferences.values());
61+
}
62+
63+
@JsonIgnore
64+
public Map<ContributedToolReference, ContributedTool> getResolvedToolReferences() {
65+
return resolvedToolReferences;
6566
}
6667

6768
public void resolveToolsDependencies(Collection<ContributedPackage> packages) {
68-
resolvedTools = new ArrayList<>();
69+
resolvedToolReferences = new HashMap<>();
6970

7071
// If there are no dependencies return empty list
7172
if (getToolsDependencies() == null) {
@@ -79,7 +80,7 @@ public void resolveToolsDependencies(Collection<ContributedPackage> packages) {
7980
if (tool == null) {
8081
System.err.println("Index error: could not find referenced tool " + dep);
8182
} else {
82-
resolvedTools.add(tool);
83+
resolvedToolReferences.put(dep, tool);
8384
}
8485
}
8586
}

arduino-core/src/cc/arduino/contributions/packages/ContributionInstaller.java

+16-9
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@
5252
import java.io.IOException;
5353
import java.net.URL;
5454
import java.nio.file.Files;
55+
import java.nio.file.Path;
56+
import java.nio.file.Paths;
5557
import java.util.*;
5658
import java.util.stream.Collectors;
5759

@@ -122,26 +124,31 @@ public synchronized List<String> install(ContributedPlatform contributedPlatform
122124
// once everything is successfully unpacked. If the operation fails remove
123125
// all the temporary folders and abort installation.
124126

125-
// Unzip tools on the correct location
126-
File toolsFolder = new File(packageFolder, "tools");
127+
List<Map.Entry<ContributedToolReference, ContributedTool>> resolvedToolReferences = contributedPlatform.getResolvedToolReferences().entrySet()
128+
.stream()
129+
.filter((entry) -> !entry.getValue().getDownloadableContribution(platform).isInstalled())
130+
.collect(Collectors.toList());
131+
132+
127133
int i = 1;
128-
for (ContributedTool tool : tools) {
129-
progress.setStatus(format(tr("Installing tools ({0}/{1})..."), i, tools.size()));
134+
for (Map.Entry<ContributedToolReference, ContributedTool> entry : resolvedToolReferences) {
135+
progress.setStatus(format(tr("Installing tools ({0}/{1})..."), i, resolvedToolReferences.size()));
130136
progressListener.onProgress(progress);
131137
i++;
138+
ContributedTool tool = entry.getValue();
132139
DownloadableContribution toolContrib = tool.getDownloadableContribution(platform);
133-
File destFolder = new File(toolsFolder, tool.getName() + File.separator + tool.getVersion());
140+
Path destFolder = Paths.get(indexer.getPackagesFolder().getAbsolutePath(), entry.getKey().getPackager(), "tools", tool.getName(), tool.getVersion());
134141

135-
Files.createDirectories(destFolder.toPath());
142+
Files.createDirectories(destFolder);
136143
assert toolContrib.getDownloadedFile() != null;
137-
new ArchiveExtractor(platform).extract(toolContrib.getDownloadedFile(), destFolder, 1);
144+
new ArchiveExtractor(platform).extract(toolContrib.getDownloadedFile(), destFolder.toFile(), 1);
138145
try {
139-
findAndExecutePostInstallScriptIfAny(destFolder, contributedPlatform.getParentPackage().isTrusted(), PreferencesData.getBoolean(Constants.PREF_CONTRIBUTIONS_TRUST_ALL));
146+
findAndExecutePostInstallScriptIfAny(destFolder.toFile(), contributedPlatform.getParentPackage().isTrusted(), PreferencesData.getBoolean(Constants.PREF_CONTRIBUTIONS_TRUST_ALL));
140147
} catch (IOException e) {
141148
errors.add(tr("Error running post install script"));
142149
}
143150
toolContrib.setInstalled(true);
144-
toolContrib.setInstalledFolder(destFolder);
151+
toolContrib.setInstalledFolder(destFolder.toFile());
145152
progress.stepDone();
146153
}
147154

arduino-core/src/cc/arduino/contributions/packages/ContributionsIndexer.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,9 @@ public void parseIndex() throws Exception {
9292
}
9393

9494
List<ContributedPackage> packages = index.getPackages();
95-
Collection<ContributedPackage> packagesWithTools = packages.stream().filter(input -> input.getTools() != null).collect(Collectors.toList());
95+
Collection<ContributedPackage> packagesWithTools = packages.stream()
96+
.filter(input -> input.getTools() != null && !input.getTools().isEmpty())
97+
.collect(Collectors.toList());
9698

9799
for (ContributedPackage pack : packages) {
98100
for (ContributedPlatform platform : pack.getPlatforms()) {

build/windows/launcher/config.xml

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919
<cp>%EXEDIR%/lib/commons-logging-1.0.4.jar</cp>
2020
<cp>%EXEDIR%/lib/commons-net-3.3.jar</cp>
2121
<cp>%EXEDIR%/lib/ecj.jar</cp>
22-
<cp>%EXEDIR%/lib/jackson-annotations-2.2.3.jar</cp>
23-
<cp>%EXEDIR%/lib/jackson-core-2.2.3.jar</cp>
24-
<cp>%EXEDIR%/lib/jackson-databind-2.2.3.jar</cp>
25-
<cp>%EXEDIR%/lib/jackson-module-mrbean-2.2.3.jar</cp>
22+
<cp>%EXEDIR%/lib/jackson-annotations-2.6.3.jar</cp>
23+
<cp>%EXEDIR%/lib/jackson-core-2.6.3.jar</cp>
24+
<cp>%EXEDIR%/lib/jackson-databind-2.6.3.jar</cp>
25+
<cp>%EXEDIR%/lib/jackson-module-mrbean-2.6.3.jar</cp>
2626
<cp>%EXEDIR%/lib/java-semver-0.8.0.jar</cp>
2727
<cp>%EXEDIR%/lib/jmdns-3.4.1.jar</cp>
2828
<cp>%EXEDIR%/lib/jna-4.1.0.jar</cp>

build/windows/launcher/config_debug.xml

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919
<cp>%EXEDIR%/lib/commons-logging-1.0.4.jar</cp>
2020
<cp>%EXEDIR%/lib/commons-net-3.3.jar</cp>
2121
<cp>%EXEDIR%/lib/ecj.jar</cp>
22-
<cp>%EXEDIR%/lib/jackson-annotations-2.2.3.jar</cp>
23-
<cp>%EXEDIR%/lib/jackson-core-2.2.3.jar</cp>
24-
<cp>%EXEDIR%/lib/jackson-databind-2.2.3.jar</cp>
25-
<cp>%EXEDIR%/lib/jackson-module-mrbean-2.2.3.jar</cp>
22+
<cp>%EXEDIR%/lib/jackson-annotations-2.6.3.jar</cp>
23+
<cp>%EXEDIR%/lib/jackson-core-2.6.3.jar</cp>
24+
<cp>%EXEDIR%/lib/jackson-databind-2.6.3.jar</cp>
25+
<cp>%EXEDIR%/lib/jackson-module-mrbean-2.6.3.jar</cp>
2626
<cp>%EXEDIR%/lib/java-semver-0.8.0.jar</cp>
2727
<cp>%EXEDIR%/lib/jmdns-3.4.1.jar</cp>
2828
<cp>%EXEDIR%/lib/jna-4.1.0.jar</cp>

0 commit comments

Comments
 (0)