24
24
import org .gradle .api .DefaultTask ;
25
25
import org .gradle .api .file .*;
26
26
import org .gradle .api .logging .*;
27
+ import org .gradle .api .model .ObjectFactory ;
27
28
import org .gradle .api .tasks .*;
28
29
import org .gradle .api .tasks .Optional ;
29
30
import org .gradle .util .GradleVersion ;
32
33
import proguard .classfile .util .ClassUtil ;
33
34
import proguard .util .ListUtil ;
34
35
36
+ import javax .inject .Inject ;
35
37
import java .io .*;
36
38
import java .net .*;
37
39
import java .util .*;
44
46
@ CacheableTask
45
47
public abstract class ProGuardTask extends DefaultTask
46
48
{
49
+ @ Inject
50
+ protected abstract ObjectFactory getObjectFactory ();
51
+ @ Inject
52
+ protected abstract ProjectLayout getProjectLayout ();
53
+
47
54
// Accumulated input and output, for the sake of Gradle's lazy file
48
55
// resolution and lazy task execution.
49
56
private final List inJarFiles = new ArrayList ();
@@ -63,16 +70,12 @@ public abstract class ProGuardTask extends DefaultTask
63
70
private ClassSpecification classSpecification ;
64
71
65
72
public static final String DEFAULT_CONFIG_RESOURCE_PREFIX = "/lib" ;
66
- private final String resolvedConfigurationFileNamePrefix = getProject ().file (DEFAULT_CONFIG_RESOURCE_PREFIX ).toString ();
73
+ private final String resolvedConfigurationFileNamePrefix = getProjectLayout ().files (DEFAULT_CONFIG_RESOURCE_PREFIX ). getSingleFile ( ).toString ();
67
74
68
75
// INTERNAL USE ONLY - write extra data entries to this jar
69
76
private File extraJar ;
70
77
71
78
public ProGuardTask () {
72
- if (GradleVersion .current ().compareTo (GradleVersion .version ("7.4" )) >= 0 ) {
73
- // This method was added in Gradle 7.4
74
- notCompatibleWithConfigurationCache ("https://github.com/Guardsquare/proguard/issues/254" );
75
- }
76
79
}
77
80
78
81
// Gradle task inputs and outputs, because annotations on the List fields
@@ -82,26 +85,26 @@ public ProGuardTask() {
82
85
@ Classpath
83
86
public FileCollection getInJarFileCollection ()
84
87
{
85
- return getProject ().files (inJarFiles );
88
+ return getProjectLayout ().files (inJarFiles );
86
89
}
87
90
88
91
@ OutputFiles
89
92
public FileCollection getOutJarFileCollection ()
90
93
{
91
- return getProject ().files (outJarFiles );
94
+ return getProjectLayout ().files (outJarFiles );
92
95
}
93
96
94
97
@ Classpath
95
98
public FileCollection getLibraryJarFileCollection ()
96
99
{
97
- return getProject ().files (libraryJarFiles );
100
+ return getProjectLayout ().files (libraryJarFiles );
98
101
}
99
102
100
103
@ InputFiles
101
104
@ PathSensitive (PathSensitivity .RELATIVE )
102
105
public FileCollection getConfigurationFileCollection ()
103
106
{
104
- return getProject ().files (configurationFiles );
107
+ return getProjectLayout ().files (configurationFiles );
105
108
}
106
109
107
110
// Convenience methods to retrieve settings from outside the task.
@@ -672,7 +675,7 @@ public void printseeds()
672
675
public void printseeds (Object printSeeds )
673
676
throws ParseException
674
677
{
675
- configuration .printSeeds = getProject ().file (printSeeds );
678
+ configuration .printSeeds = getProjectLayout ().files (printSeeds ). getSingleFile ( );
676
679
}
677
680
678
681
@ Optional
@@ -710,7 +713,7 @@ public void printusage()
710
713
public void printusage (Object printUsage )
711
714
throws ParseException
712
715
{
713
- configuration .printUsage = getProject ().file (printUsage );
716
+ configuration .printUsage = getProjectLayout ().files (printUsage ). getSingleFile ( );
714
717
}
715
718
716
719
@ Optional
@@ -925,7 +928,7 @@ public void printmapping()
925
928
public void printmapping (Object printMapping )
926
929
throws ParseException
927
930
{
928
- configuration .printMapping = getProject ().file (printMapping );
931
+ configuration .printMapping = getProjectLayout ().files (printMapping ). getSingleFile ( );
929
932
}
930
933
931
934
@ Optional
@@ -937,7 +940,7 @@ public File getPrintMappingFile() {
937
940
public void applymapping (Object applyMapping )
938
941
throws ParseException
939
942
{
940
- configuration .applyMapping = getProject ().file (applyMapping );
943
+ configuration .applyMapping = getProjectLayout ().files (applyMapping ). getSingleFile ( );
941
944
}
942
945
943
946
public void obfuscationdictionary (Object obfuscationDictionary )
@@ -1219,7 +1222,7 @@ public void android()
1219
1222
public void keystore (Object keyStore )
1220
1223
{
1221
1224
configuration .keyStores =
1222
- extendList (configuration .keyStores , getProject ().file (keyStore ));
1225
+ extendList (configuration .keyStores , getProjectLayout ().files (keyStore ). getSingleFile ( ));
1223
1226
}
1224
1227
1225
1228
public void keystorepassword (String keyStorePassword )
@@ -1321,7 +1324,7 @@ public void printconfiguration(Object printConfiguration)
1321
1324
throws ParseException
1322
1325
{
1323
1326
configuration .printConfiguration =
1324
- getProject ().file (printConfiguration );
1327
+ getProjectLayout ().files (printConfiguration ). getSingleFile ( );
1325
1328
}
1326
1329
1327
1330
@ Optional
@@ -1346,7 +1349,7 @@ public void dump()
1346
1349
public void dump (Object dump )
1347
1350
throws ParseException
1348
1351
{
1349
- configuration .dump = getProject ().file (dump );
1352
+ configuration .dump = getProjectLayout ().files (dump ). getSingleFile ( );
1350
1353
}
1351
1354
1352
1355
@ Optional
@@ -1490,7 +1493,7 @@ private Configuration getConfiguration() throws Exception
1490
1493
Object fileObject = configurationFiles .get (index );
1491
1494
1492
1495
ConfigurableFileCollection fileCollection =
1493
- getProject ().files (fileObject );
1496
+ getObjectFactory ().fileCollection (). from (fileObject );
1494
1497
1495
1498
// Parse the configuration as a collection of files.
1496
1499
Iterator <File > files = fileCollection .iterator ();
@@ -1595,7 +1598,7 @@ private ClassPath extendClassPath(ClassPath classPath,
1595
1598
Map filterArgs ,
1596
1599
boolean output )
1597
1600
{
1598
- ConfigurableFileCollection fileCollection = getProject ().files (files );
1601
+ ConfigurableFileCollection fileCollection = getObjectFactory ().fileCollection (). from (files );
1599
1602
1600
1603
if (classPath == null )
1601
1604
{
@@ -2299,7 +2302,7 @@ private List extendList(List list, Object object)
2299
2302
*/
2300
2303
private URL url (Object fileObject ) throws MalformedURLException
2301
2304
{
2302
- File file = getProject ().file (fileObject );
2305
+ File file = getProjectLayout ().files (fileObject ). getSingleFile ( );
2303
2306
return
2304
2307
fileObject instanceof URL ? (URL )fileObject :
2305
2308
fileObject instanceof String &&
0 commit comments