Skip to content

Commit 5a49834

Browse files
author
Barry Warsaw
committed
Make ZipappExtension an interface and add some @deprecated annotations
1 parent 19e7155 commit 5a49834

File tree

4 files changed

+42
-37
lines changed

4 files changed

+42
-37
lines changed

pygradle-plugin/src/main/groovy/com/linkedin/gradle/python/extension/PexExtension.java

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,43 +15,64 @@
1515
*/
1616
package com.linkedin.gradle.python.extension;
1717

18+
import com.linkedin.gradle.python.util.OperatingSystem;
1819
import org.gradle.api.Project;
1920

2021
import java.io.File;
2122

2223

23-
public class PexExtension extends ZipappExtension {
24+
public class PexExtension implements ZipappExtension {
25+
private File cache;
26+
// Default to fat zipapps on Windows, since our wrappers are fairly POSIX specific.
27+
private boolean isFat = OperatingSystem.current().isWindows();
2428
private boolean pythonWrapper = true;
2529

2630
public PexExtension(Project project) {
27-
super(new File(project.getBuildDir(), "pex-cache"));
31+
this.cache = new File(project.getBuildDir(), "pex-cache");
2832
}
2933

30-
// These are kept for API backward compatibility.
31-
3234
public File getPexCache() {
33-
return getCache();
35+
return cache;
3436
}
3537

36-
3738
public void setPexCache(File pexCache) {
38-
super.setCache(pexCache);
39+
cache = pexCache;
3940
}
4041

42+
// These are kept for API backward compatibility.
43+
4144
/**
4245
* @return when <code>true</code>, then skinny pex's will be used.
4346
*/
47+
@Deprecated
4448
public boolean isFatPex() {
4549
return isFat();
4650
}
4751

4852
/**
4953
* @param fatPex when <code>true</code>, wrappers will be made all pointing to a single pex file.
5054
*/
55+
@Deprecated
5156
public void setFatPex(boolean fatPex) {
52-
super.setIsFat(fatPex);
57+
isFat = fatPex;
5358
}
5459

60+
// Use these properties instead.
61+
62+
/**
63+
* @return when <code>true</code>, then skinny pex's will be used.
64+
*/
65+
public boolean isFat() {
66+
return isFat;
67+
}
68+
69+
/**
70+
* @param fat when <code>true</code>, wrappers will be made all pointing to a single pex file.
71+
*/
72+
public void setIsFat(boolean isFat) {
73+
this.isFat = isFat;
74+
}
75+
5576
/**
5677
* TODO: Revisit if this is needed.
5778
*
@@ -64,4 +85,12 @@ public boolean isPythonWrapper() {
6485
public void setPythonWrapper(boolean pythonWrapper) {
6586
this.pythonWrapper = pythonWrapper;
6687
}
88+
89+
public File getCache() {
90+
return cache;
91+
}
92+
93+
public void setCache(File cache) {
94+
this.cache = cache;
95+
}
6796
}

pygradle-plugin/src/main/groovy/com/linkedin/gradle/python/extension/ZipappExtension.java

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -15,39 +15,15 @@
1515
*/
1616
package com.linkedin.gradle.python.extension;
1717

18-
import com.linkedin.gradle.python.util.OperatingSystem;
19-
20-
import java.io.File;
21-
22-
23-
public class ZipappExtension {
24-
private File cache;
25-
// Default to fat zipapps on Windows, since our wrappers are fairly POSIX specific.
26-
private boolean isFat = OperatingSystem.current().isWindows();
27-
28-
public ZipappExtension(File cache) {
29-
this.cache = cache;
30-
}
31-
32-
public File getCache() {
33-
return cache;
34-
}
35-
36-
public void setCache(File cache) {
37-
this.cache = cache;
38-
}
3918

19+
public interface ZipappExtension {
4020
/**
4121
* @return when <code>true</code>, then skinny pex's will be used.
4222
*/
43-
public boolean isFat() {
44-
return isFat;
45-
}
23+
public boolean isFat();
4624

4725
/**
4826
* @param fat when <code>true</code>, wrappers will be made all pointing to a single pex file.
4927
*/
50-
public void setIsFat(boolean isFat) {
51-
this.isFat = isFat;
52-
}
28+
public void setIsFat(boolean isFat);
5329
}

pygradle-plugin/src/main/groovy/com/linkedin/gradle/python/tasks/BuildPexTask.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public void buildPex() throws Exception {
8787

8888
deployableExtension.getDeployableBuildDir().mkdirs();
8989

90-
if (pexExtension.isFatPex()) {
90+
if (pexExtension.isFat()) {
9191
new FatPexGenerator(project, pexOptions).buildEntryPoints();
9292
} else {
9393
new ThinPexGenerator(project, pexOptions, templateProvider, additionalProperties).buildEntryPoints();

pygradle-plugin/src/main/groovy/com/linkedin/gradle/python/tasks/BuildWebAppTask.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public void buildWebapp() throws IOException, ClassNotFoundException {
6767
Project project = getProject();
6868
PexExtension pexExtension = ExtensionUtils.getPythonComponentExtension(project, PexExtension.class);
6969

70-
if (pexExtension.isFatPex()) {
70+
if (pexExtension.isFat()) {
7171
new FatPexGenerator(project, pexOptions).buildEntryPoint(
7272
PexFileUtil.createFatPexFilename(executable.getName()), entryPoint, null);
7373
} else {

0 commit comments

Comments
 (0)