Skip to content

Commit 4e37df1

Browse files
committed
GH-417: Deprecate obscure methods in JctFileManager and Workspace
1 parent 8da7ca6 commit 4e37df1

File tree

4 files changed

+143
-8
lines changed

4 files changed

+143
-8
lines changed

java-compiler-testing/src/main/java/io/github/ascopes/jct/filemanagers/JctFileManager.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,13 @@ default PackageContainerGroup getPlatformClassPathGroup() {
267267
*
268268
* @return the location, or {@code null} if the location is not present in the file manager.
269269
* @since 0.1.0
270+
* @deprecated This is a specialist method that is usually not used. To keep the API simple,
271+
* this is being removed. You should instead call {@link #getOutputContainerGroup(Location)},
272+
* passing {@link StandardLocation#NATIVE_HEADER_OUTPUT} as the first parameter.
270273
*/
274+
@Deprecated(since = "0.6.0", forRemoval = true)
271275
@Nullable
276+
@SuppressWarnings("DeprecatedIsStillUsed")
272277
default OutputContainerGroup getNativeHeaderOutputGroup() {
273278
return getOutputContainerGroup(StandardLocation.NATIVE_HEADER_OUTPUT);
274279
}
@@ -289,8 +294,13 @@ default ModuleContainerGroup getModuleSourcePathGroup() {
289294
*
290295
* @return the location, or {@code null} if the location is not present in the file manager.
291296
* @since 0.1.0
297+
* @deprecated This is a specialist method that is usually not used. To keep the API simple,
298+
* this is being removed. You should instead call {@link #getModuleContainerGroup(Location)},
299+
* passing {@link StandardLocation#SYSTEM_MODULES} as the first parameter.
292300
*/
301+
@Deprecated(since = "0.6.0", forRemoval = true)
293302
@Nullable
303+
@SuppressWarnings("DeprecatedIsStillUsed")
294304
default ModuleContainerGroup getUpgradeModulePathGroup() {
295305
return getModuleContainerGroup(StandardLocation.UPGRADE_MODULE_PATH);
296306
}
@@ -300,8 +310,13 @@ default ModuleContainerGroup getUpgradeModulePathGroup() {
300310
*
301311
* @return the location, or {@code null} if the location is not present in the file manager.
302312
* @since 0.1.0
313+
* @deprecated This is a specialist method that is usually not used. To keep the API simple,
314+
* this is being removed. You should instead call {@link #getModuleContainerGroup(Location)},
315+
* passing {@link StandardLocation#SYSTEM_MODULES} as the first parameter.
303316
*/
317+
@Deprecated(since = "0.6.0", forRemoval = true)
304318
@Nullable
319+
@SuppressWarnings("DeprecatedIsStillUsed")
305320
default ModuleContainerGroup getSystemModulesGroup() {
306321
return getModuleContainerGroup(StandardLocation.SYSTEM_MODULES);
307322
}
@@ -322,8 +337,13 @@ default ModuleContainerGroup getModulePathGroup() {
322337
*
323338
* @return the location, or {@code null} if the location is not present in the file manager.
324339
* @since 0.1.0
340+
* @deprecated This is a specialist method that is usually not used. To keep the API simple,
341+
* this is being removed. You should instead call {@link #getModuleContainerGroup(Location)},
342+
* passing {@link StandardLocation#PATCH_MODULE_PATH} as the first parameter.
325343
*/
344+
@Deprecated(since = "0.6.0", forRemoval = true)
326345
@Nullable
346+
@SuppressWarnings("DeprecatedIsStillUsed")
327347
default ModuleContainerGroup getPatchModulePathGroup() {
328348
return getModuleContainerGroup(StandardLocation.PATCH_MODULE_PATH);
329349
}

java-compiler-testing/src/main/java/io/github/ascopes/jct/workspaces/Workspace.java

Lines changed: 99 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,12 @@ default void addPlatformClassPathPackage(Path path) {
531531
* @see #addNativeHeaderOutputModule(String, Path)
532532
* @see #createNativeHeaderOutputPackage()
533533
* @see #createNativeHeaderOutputModule(String)
534+
* @deprecated This is a specialist method that is usually not used. To keep the API simple,
535+
* this is being removed. You should instead call {@link #addPackage(Location, Path)}, passing
536+
* {@link StandardLocation#NATIVE_HEADER_OUTPUT} as the first parameter.
534537
*/
538+
@Deprecated(forRemoval = true, since = "0.6.0")
539+
@SuppressWarnings("DeprecatedIsStillUsed")
535540
default void addNativeHeaderOutputPackage(Path path) {
536541
addPackage(StandardLocation.NATIVE_HEADER_OUTPUT, path);
537542
}
@@ -546,7 +551,12 @@ default void addNativeHeaderOutputPackage(Path path) {
546551
* @see #addNativeHeaderOutputPackage(Path)
547552
* @see #createNativeHeaderOutputPackage()
548553
* @see #createNativeHeaderOutputModule(String)
554+
* @deprecated This is a specialist method that is usually not used. To keep the API simple,
555+
* this is being removed. You should instead call {@link #addModule(Location, String, Path)},
556+
* passing {@link StandardLocation#NATIVE_HEADER_OUTPUT} as the first parameter.
549557
*/
558+
@Deprecated(forRemoval = true, since = "0.6.0")
559+
@SuppressWarnings("DeprecatedIsStillUsed")
550560
default void addNativeHeaderOutputModule(String moduleName, Path path) {
551561
addModule(StandardLocation.NATIVE_HEADER_OUTPUT, moduleName, path);
552562
}
@@ -559,7 +569,12 @@ default void addNativeHeaderOutputModule(String moduleName, Path path) {
559569
* @throws IllegalArgumentException if the path does not exist.
560570
* @see #addModule(Location, String, Path)
561571
* @see #createUpgradeModulePathModule(String)
572+
* @deprecated This is a specialist method that is usually not used. To keep the API simple,
573+
* this is being removed. You should instead call {@link #addModule(Location, String, Path)},
574+
* passing {@link StandardLocation#UPGRADE_MODULE_PATH} as the first parameter.
562575
*/
576+
@Deprecated(forRemoval = true, since = "0.6.0")
577+
@SuppressWarnings("DeprecatedIsStillUsed")
563578
default void addUpgradeModulePathModule(String moduleName, Path path) {
564579
addModule(StandardLocation.UPGRADE_MODULE_PATH, moduleName, path);
565580
}
@@ -571,8 +586,12 @@ default void addUpgradeModulePathModule(String moduleName, Path path) {
571586
* @param path the path to add.
572587
* @throws IllegalArgumentException if the path does not exist.
573588
* @see #addModule(Location, String, Path)
574-
* @see #createSystemModulePathModule(String)
589+
* @deprecated This is a specialist method that is usually not used. To keep the API simple,
590+
* this is being removed. You should instead call {@link #addModule(Location, String, Path)},
591+
* passing {@link StandardLocation#SYSTEM_MODULES} as the first parameter.
575592
*/
593+
@Deprecated(forRemoval = true, since = "0.6.0")
594+
@SuppressWarnings("DeprecatedIsStillUsed")
576595
default void addSystemModulePathModule(String moduleName, Path path) {
577596
addModule(StandardLocation.SYSTEM_MODULES, moduleName, path);
578597
}
@@ -585,7 +604,12 @@ default void addSystemModulePathModule(String moduleName, Path path) {
585604
* @throws IllegalArgumentException if the path does not exist.
586605
* @see #addModule(Location, String, Path)
587606
* @see #createPatchModulePathModule(String)
607+
* @deprecated This is a specialist method that is usually not used. To keep the API simple,
608+
* this is being removed. You should instead call {@link #addModule(Location, String, Path)},
609+
* passing {@link StandardLocation#PATCH_MODULE_PATH} as the first parameter.
588610
*/
611+
@Deprecated(forRemoval = true, since = "0.6.0")
612+
@SuppressWarnings("DeprecatedIsStillUsed")
589613
default void addPatchModulePathModule(String moduleName, Path path) {
590614
addModule(StandardLocation.PATCH_MODULE_PATH, moduleName, path);
591615
}
@@ -777,7 +801,12 @@ default ManagedDirectory createPlatformClassPathPackage() {
777801
* @see #createNativeHeaderOutputModule(String)
778802
* @see #addNativeHeaderOutputPackage(Path)
779803
* @see #addNativeHeaderOutputModule(String, Path)
804+
* @deprecated This is a specialist method that is usually not used. To keep the API simple,
805+
* this is being removed. You should instead call {@link #createPackage(Location)}, passing
806+
* {@link StandardLocation#NATIVE_HEADER_OUTPUT} as the first parameter.
780807
*/
808+
@Deprecated(forRemoval = true, since = "0.6.0")
809+
@SuppressWarnings("DeprecatedIsStillUsed")
781810
default ManagedDirectory createNativeHeaderOutputPackage() {
782811
return createPackage(StandardLocation.NATIVE_HEADER_OUTPUT);
783812
}
@@ -791,7 +820,12 @@ default ManagedDirectory createNativeHeaderOutputPackage() {
791820
* @see #createNativeHeaderOutputPackage()
792821
* @see #addNativeHeaderOutputPackage(Path)
793822
* @see #addNativeHeaderOutputModule(String, Path)
823+
* @deprecated This is a specialist method that is usually not used. To keep the API simple,
824+
* this is being removed. You should instead call {@link #createModule(Location, String)}, passing
825+
* {@link StandardLocation#NATIVE_HEADER_OUTPUT} as the first parameter.
794826
*/
827+
@Deprecated(forRemoval = true, since = "0.6.0")
828+
@SuppressWarnings("DeprecatedIsStillUsed")
795829
default ManagedDirectory createNativeHeaderOutputModule(String moduleName) {
796830
return createModule(StandardLocation.NATIVE_HEADER_OUTPUT, moduleName);
797831
}
@@ -803,7 +837,12 @@ default ManagedDirectory createNativeHeaderOutputModule(String moduleName) {
803837
* @return the created test directory.
804838
* @see #createModule(Location, String)
805839
* @see #addUpgradeModulePathModule(String, Path)
840+
* @deprecated This is a specialist method that is usually not used. To keep the API simple,
841+
* this is being removed. You should instead call {@link #createModule(Location, String)},
842+
* passing {@link StandardLocation#UPGRADE_MODULE_PATH} as the first parameter.
806843
*/
844+
@Deprecated(forRemoval = true, since = "0.6.0")
845+
@SuppressWarnings("DeprecatedIsStillUsed")
807846
default ManagedDirectory createUpgradeModulePathModule(String moduleName) {
808847
return createModule(StandardLocation.UPGRADE_MODULE_PATH, moduleName);
809848
}
@@ -815,7 +854,12 @@ default ManagedDirectory createUpgradeModulePathModule(String moduleName) {
815854
* @return the created test directory.
816855
* @see #createModule(Location, String)
817856
* @see #addSystemModulePathModule(String, Path)
857+
* @deprecated This is a specialist method that is usually not used. To keep the API simple,
858+
* this is being removed. You should instead call {@link #createModule(Location, String)}, passing
859+
* {@link StandardLocation#SYSTEM_MODULES} as the first parameter.
818860
*/
861+
@Deprecated(forRemoval = true, since = "0.6.0")
862+
@SuppressWarnings("DeprecatedIsStillUsed")
819863
default ManagedDirectory createSystemModulePathModule(String moduleName) {
820864
return createModule(StandardLocation.SYSTEM_MODULES, moduleName);
821865
}
@@ -827,7 +871,12 @@ default ManagedDirectory createSystemModulePathModule(String moduleName) {
827871
* @return the created test directory.
828872
* @see #createModule(Location, String)
829873
* @see #createPatchModulePathModule(String)
874+
* @deprecated This is a specialist method that is usually not used. To keep the API simple,
875+
* this is being removed. You should instead call {@link #createModule(Location, String)}, passing
876+
* {@link StandardLocation#PATCH_MODULE_PATH} as the first parameter.
830877
*/
878+
@Deprecated(forRemoval = true, since = "0.6.0")
879+
@SuppressWarnings("DeprecatedIsStillUsed")
831880
default ManagedDirectory createPatchModulePathModule(String moduleName) {
832881
return createModule(StandardLocation.PATCH_MODULE_PATH, moduleName);
833882
}
@@ -960,7 +1009,11 @@ default Map<String, List<? extends PathRoot>> getAnnotationProcessorPathModules(
9601009
*
9611010
* @return the roots in a collection, or an empty collection if none were found.
9621011
* @since 0.1.0
1012+
* @deprecated The platform class path has been mostly replaced by the use of system modules, so
1013+
* should not be used. This will be removed in v1.0.0.
9631014
*/
1015+
@Deprecated(forRemoval = true, since = "0.6.0")
1016+
@SuppressWarnings("DeprecatedIsStillUsed")
9641017
default List<? extends PathRoot> getPlatformClassPathPackages() {
9651018
return getPackages(StandardLocation.PLATFORM_CLASS_PATH);
9661019
}
@@ -971,7 +1024,12 @@ default List<? extends PathRoot> getPlatformClassPathPackages() {
9711024
*
9721025
* @return the roots in a collection, or an empty collection if none were found.
9731026
* @since 0.1.0
1027+
* @deprecated This is a specialist method that is usually not used. To keep the API simple,
1028+
* this is being removed. You should instead call {@link #getPackages(Location)}, passing
1029+
* {@link StandardLocation#NATIVE_HEADER_OUTPUT} as the first parameter.
9741030
*/
1031+
@Deprecated(forRemoval = true, since = "0.6.0")
1032+
@SuppressWarnings("DeprecatedIsStillUsed")
9751033
default List<? extends PathRoot> getNativeHeaderOutputPackages() {
9761034
return getPackages(StandardLocation.NATIVE_HEADER_OUTPUT);
9771035
}
@@ -983,7 +1041,12 @@ default List<? extends PathRoot> getNativeHeaderOutputPackages() {
9831041
* @param moduleName the module name.
9841042
* @return the roots in a collection, or an empty collection if none were found.
9851043
* @since 0.1.0
1044+
* @deprecated This is a specialist method that is usually not used. To keep the API simple,
1045+
* this is being removed. You should instead call {@link #getModule(Location, String)}, passing
1046+
* {@link StandardLocation#NATIVE_HEADER_OUTPUT} as the first parameter.
9861047
*/
1048+
@Deprecated(forRemoval = true, since = "0.6.0")
1049+
@SuppressWarnings("DeprecatedIsStillUsed")
9871050
default List<? extends PathRoot> getNativeHeaderOutputModule(String moduleName) {
9881051
return getModule(StandardLocation.NATIVE_HEADER_OUTPUT, moduleName);
9891052
}
@@ -995,7 +1058,12 @@ default List<? extends PathRoot> getNativeHeaderOutputModule(String moduleName)
9951058
* @return the roots in a map of module names to lists of roots, or an empty map if none were
9961059
* found.
9971060
* @since 0.1.0
1061+
* @deprecated This is a specialist method that is usually not used. To keep the API simple,
1062+
* this is being removed. You should instead call {@link #getModules(Location)}, passing
1063+
* {@link StandardLocation#NATIVE_HEADER_OUTPUT} as the first parameter.
9981064
*/
1065+
@Deprecated(forRemoval = true, since = "0.6.0")
1066+
@SuppressWarnings("DeprecatedIsStillUsed")
9991067
default Map<String, List<? extends PathRoot>> getNativeHeaderOutputModules() {
10001068
return getModules(StandardLocation.NATIVE_HEADER_OUTPUT);
10011069
}
@@ -1029,7 +1097,12 @@ default Map<String, List<? extends PathRoot>> getSourcePathModules() {
10291097
* @param moduleName the module name to get.
10301098
* @return the roots in a collection, or an empty collection if none were found.
10311099
* @since 0.1.0
1100+
* @deprecated This is a specialist method that is usually not used. To keep the API simple,
1101+
* this is being removed. You should instead call {@link #getModule(Location, String)}, passing
1102+
* {@link StandardLocation#UPGRADE_MODULE_PATH} as the first parameter.
10321103
*/
1104+
@Deprecated(forRemoval = true, since = "0.6.0")
1105+
@SuppressWarnings("DeprecatedIsStillUsed")
10331106
default List<? extends PathRoot> getUpgradeModulePathModule(String moduleName) {
10341107
return getModule(StandardLocation.UPGRADE_MODULE_PATH, moduleName);
10351108
}
@@ -1041,7 +1114,12 @@ default List<? extends PathRoot> getUpgradeModulePathModule(String moduleName) {
10411114
* @return the roots in a map of module names to lists of roots, or an empty map if none were
10421115
* found.
10431116
* @since 0.1.0
1117+
* @deprecated This is a specialist method that is usually not used. To keep the API simple,
1118+
* this is being removed. You should instead call {@link #getModules(Location)}, passing
1119+
* {@link StandardLocation#UPGRADE_MODULE_PATH} as the first parameter.
10441120
*/
1121+
@Deprecated(forRemoval = true, since = "0.6.0")
1122+
@SuppressWarnings("DeprecatedIsStillUsed")
10451123
default Map<String, List<? extends PathRoot>> getUpgradeModulePathModules() {
10461124
return getModules(StandardLocation.UPGRADE_MODULE_PATH);
10471125
}
@@ -1052,7 +1130,12 @@ default Map<String, List<? extends PathRoot>> getUpgradeModulePathModules() {
10521130
* @param moduleName the module name to get.
10531131
* @return the roots in a collection, or an empty collection if none were found.
10541132
* @since 0.1.0
1133+
* @deprecated This is a specialist method that is usually not used. To keep the API simple,
1134+
* this is being removed. You should instead call {@link #getModule(Location, String)}, passing
1135+
* {@link StandardLocation#SYSTEM_MODULES} as the first parameter.
10551136
*/
1137+
@Deprecated(forRemoval = true, since = "0.6.0")
1138+
@SuppressWarnings("DeprecatedIsStillUsed")
10561139
default List<? extends PathRoot> getSystemModulePathModule(String moduleName) {
10571140
return getModule(StandardLocation.SYSTEM_MODULES, moduleName);
10581141
}
@@ -1063,7 +1146,12 @@ default List<? extends PathRoot> getSystemModulePathModule(String moduleName) {
10631146
* @return the roots in a map of module names to lists of roots, or an empty map if none were
10641147
* found.
10651148
* @since 0.1.0
1149+
* @deprecated This is a specialist method that is usually not used. To keep the API simple,
1150+
* this is being removed. You should instead call {@link #getModules(Location)}, passing
1151+
* {@link StandardLocation#SYSTEM_MODULES} as the first parameter.
10661152
*/
1153+
@Deprecated(forRemoval = true, since = "0.6.0")
1154+
@SuppressWarnings("DeprecatedIsStillUsed")
10671155
default Map<String, List<? extends PathRoot>> getSystemModulePathModules() {
10681156
return getModules(StandardLocation.SYSTEM_MODULES);
10691157
}
@@ -1096,7 +1184,12 @@ default Map<String, List<? extends PathRoot>> getModulePathModules() {
10961184
* @param moduleName the module name to get.
10971185
* @return the roots in a collection, or an empty collection if none were found.
10981186
* @since 0.1.0
1187+
* @deprecated This is a specialist method that is usually not used. To keep the API simple,
1188+
* this is being removed. You should instead call {@link #getModule(Location, String)}, passing
1189+
* {@link StandardLocation#PATCH_MODULE_PATH} as the first parameter.
10991190
*/
1191+
@Deprecated(forRemoval = true, since = "0.6.0")
1192+
@SuppressWarnings("DeprecatedIsStillUsed")
11001193
default List<? extends PathRoot> getPatchModulePathModule(String moduleName) {
11011194
return getModule(StandardLocation.PATCH_MODULE_PATH, moduleName);
11021195
}
@@ -1108,7 +1201,12 @@ default List<? extends PathRoot> getPatchModulePathModule(String moduleName) {
11081201
* @return the roots in a map of module names to lists of roots, or an empty map if none were
11091202
* found.
11101203
* @since 0.1.0
1204+
* @deprecated This is a specialist method that is usually not used. To keep the API simple,
1205+
* this is being removed. You should instead call {@link #getModules(Location)}, passing
1206+
* {@link StandardLocation#PATCH_MODULE_PATH} as the first parameter.
11111207
*/
1208+
@Deprecated(forRemoval = true, since = "0.6.0")
1209+
@SuppressWarnings("DeprecatedIsStillUsed")
11121210
default Map<String, List<? extends PathRoot>> getPatchModulePathModules() {
11131211
return getModules(StandardLocation.PATCH_MODULE_PATH);
11141212
}

java-compiler-testing/src/test/java/io/github/ascopes/jct/tests/unit/filemanagers/JctFileManagerTest.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ void getPlatformClassPathGroupMakesTheExpectedCall(PackageContainerGroup expecte
170170
@DisplayName(".getNativeHeaderOutputGroup() makes the expected call")
171171
@MethodSource("outputContainerGroupResults")
172172
@ParameterizedTest(name = "when internal getter returns {0}")
173+
@SuppressWarnings("removal")
173174
void getNativeHeaderOutputGroupMakesTheExpectedCall(OutputContainerGroup expected) {
174175
// Given
175176
when(fileManager.getNativeHeaderOutputGroup()).thenCallRealMethod();
@@ -204,6 +205,7 @@ void getModuleSourcePathGroupMakesTheExpectedCall(ModuleContainerGroup expected)
204205
@DisplayName(".getUpgradeModulePathGroup() makes the expected call")
205206
@MethodSource("moduleContainerGroupResults")
206207
@ParameterizedTest(name = "when internal getter returns {0}")
208+
@SuppressWarnings("removal")
207209
void getUpgradeModulePathGroupMakesTheExpectedCall(ModuleContainerGroup expected) {
208210
// Given
209211
when(fileManager.getUpgradeModulePathGroup()).thenCallRealMethod();
@@ -221,6 +223,7 @@ void getUpgradeModulePathGroupMakesTheExpectedCall(ModuleContainerGroup expected
221223
@DisplayName(".getSystemModulesGroup() makes the expected call")
222224
@MethodSource("moduleContainerGroupResults")
223225
@ParameterizedTest(name = "when internal getter returns {0}")
226+
@SuppressWarnings("removal")
224227
void getSystemModulesGroupMakesTheExpectedCall(ModuleContainerGroup expected) {
225228
// Given
226229
when(fileManager.getSystemModulesGroup()).thenCallRealMethod();
@@ -255,6 +258,7 @@ void getModulePathGroupMakesTheExpectedCall(ModuleContainerGroup expected) {
255258
@DisplayName(".getPatchModulePathGroup() makes the expected call")
256259
@MethodSource("moduleContainerGroupResults")
257260
@ParameterizedTest(name = "when internal getter returns {0}")
261+
@SuppressWarnings("removal")
258262
void getPatchModulePathGroupMakesTheExpectedCall(ModuleContainerGroup expected) {
259263
// Given
260264
when(fileManager.getPatchModulePathGroup()).thenCallRealMethod();
@@ -283,11 +287,4 @@ static Stream<OutputContainerGroup> outputContainerGroupResults() {
283287
null
284288
);
285289
}
286-
287-
static Stream<PackageContainerGroup> packageContainerGroupResults() {
288-
return Stream.of(
289-
mock(PackageContainerGroup.class, "a package container group"),
290-
null
291-
);
292-
}
293290
}

0 commit comments

Comments
 (0)