1+ package io .github .david0x03 .project ;
2+
3+ import java .io .IOException ;
4+ import java .nio .file .Files ;
5+ import java .nio .file .Path ;
6+ import java .util .Collections ;
7+ import java .util .List ;
8+
9+
10+ /**
11+ * Represents a Gradle-based Java project, providing methods to identify the Gradle
12+ * configuration, extract Java source version, build the project, and manage dependencies.
13+ */
14+ public class AntProject extends JavaProject {
15+
16+ /**
17+ * Initializes a Ant project instance.
18+ *
19+ * @param projectPath The path to the project directory.
20+ */
21+ public AntProject (Path projectPath ) {
22+ super (projectPath );
23+ this .getSources ().add (new JavaSource (this , projectPath ));
24+ }
25+
26+ /**
27+ * Verifies whether the specified path contains a valid Gradle project.
28+ *
29+ * @param projectPath The path to the project directory.
30+ * @return True if the project is a Ant project, otherwise false.
31+ */
32+ public static boolean isValidProject (Path projectPath ) {
33+ return Files .exists (projectPath .resolve ("build.xml" ));
34+ }
35+
36+ /**
37+ * Retrieves the Java source version used by the project by executing Gradle commands.
38+ *
39+ * @return The Java source version as a string, or null if it cannot be determined.
40+ */
41+ @ Override
42+ public String getJavaSourceVersion () {
43+ return javaSourceVersion ;
44+ }
45+
46+ /**
47+ * Mocks building the project by executing Ant commands.
48+ *
49+ * @return True if the build is successful, otherwise false.
50+ */
51+ @ Override
52+ public boolean buildProject () {
53+ return true ;
54+ }
55+
56+ /**
57+ * Retrieves the external dependencies of the project.
58+ *
59+ * @param source The Java source file whose dependencies are to be retrieved.
60+ * @return A list of paths to dependency files.
61+ */
62+ @ Override
63+ protected List <Path > getDependencies (JavaSource source ) {
64+ return Collections .emptyList ();
65+ }
66+
67+ /**
68+ * Retrieves the files generated by Ant during the build process.
69+ *
70+ * @param source The Java source file to check for generated files.
71+ * @return A list of paths to generated files.
72+ */
73+ @ Override
74+ protected List <String > getGeneratedFiles (JavaSource source ) {
75+ return Collections .emptyList ();
76+ }
77+ }
0 commit comments