@@ -18,6 +18,8 @@ pub use tmc_langs_framework::{
1818 NothingIsStudentFilePolicy , RunResult , StudentFilePolicy , StyleValidationResult ,
1919 StyleValidationStrategy ,
2020} ;
21+ // the Java plugin is disabled on musl
22+ #[ cfg( not( target_env = "musl" ) ) ]
2123pub use tmc_langs_java:: { AntPlugin , MavenPlugin } ;
2224pub use tmc_langs_make:: MakePlugin ;
2325pub use tmc_langs_notests:: NoTestsPlugin ;
@@ -62,19 +64,17 @@ pub fn compress_project(
6264}
6365
6466/// Enum containing variants for each language plugin.
65- #[ impl_enum:: with_methods(
66- pub fn clean( & self , path: & Path ) -> Result <( ) , TmcError >
67- pub fn scan_exercise( & self , path: & Path , exercise_name: String ) -> Result <ExerciseDesc , TmcError >
68- pub fn run_tests( & self , path: & Path ) -> Result <RunResult , TmcError >
69- pub fn check_code_style( & self , path: & Path , locale: Language ) -> Result <Option <StyleValidationResult >, TmcError >
70- ) ]
7167pub enum Plugin {
7268 CSharp ( CSharpPlugin ) ,
7369 Make ( MakePlugin ) ,
70+ // the Java plugin is disabled on musl
71+ #[ cfg( not( target_env = "musl" ) ) ]
7472 Maven ( MavenPlugin ) ,
7573 NoTests ( NoTestsPlugin ) ,
7674 Python3 ( Python3Plugin ) ,
7775 R ( RPlugin ) ,
76+ // the Java plugin is disabled on musl
77+ #[ cfg( not( target_env = "musl" ) ) ]
7878 Ant ( AntPlugin ) ,
7979}
8080
@@ -87,22 +87,102 @@ impl Plugin {
8787 PluginType :: Make => Plugin :: Make ( MakePlugin :: new ( ) ) ,
8888 PluginType :: Python3 => Plugin :: Python3 ( Python3Plugin :: new ( ) ) ,
8989 PluginType :: R => Plugin :: R ( RPlugin :: new ( ) ) ,
90+ // the Java plugin is disabled on musl
91+ #[ cfg( not( target_env = "musl" ) ) ]
9092 PluginType :: Maven => Plugin :: Maven ( MavenPlugin :: new ( ) ?) ,
93+ // the Java plugin is disabled on musl
94+ #[ cfg( not( target_env = "musl" ) ) ]
9195 PluginType :: Ant => Plugin :: Ant ( AntPlugin :: new ( ) ?) ,
9296 } ;
9397 Ok ( plugin)
9498 }
99+
100+ pub fn clean ( & self , path : & Path ) -> Result < ( ) , TmcError > {
101+ match self {
102+ Plugin :: CSharp ( plugin) => plugin. clean ( path) ,
103+ Plugin :: Make ( plugin) => plugin. clean ( path) ,
104+ // the Java plugin is disabled on musl
105+ #[ cfg( not( target_env = "musl" ) ) ]
106+ Plugin :: Maven ( plugin) => plugin. clean ( path) ,
107+ Plugin :: NoTests ( plugin) => plugin. clean ( path) ,
108+ Plugin :: Python3 ( plugin) => plugin. clean ( path) ,
109+ Plugin :: R ( plugin) => plugin. clean ( path) ,
110+ // the Java plugin is disabled on musl
111+ #[ cfg( not( target_env = "musl" ) ) ]
112+ Plugin :: Ant ( plugin) => plugin. clean ( path) ,
113+ }
114+ }
115+
116+ pub fn scan_exercise (
117+ & self ,
118+ path : & Path ,
119+ exercise_name : String ,
120+ ) -> Result < ExerciseDesc , TmcError > {
121+ match self {
122+ Plugin :: CSharp ( plugin) => plugin. scan_exercise ( path, exercise_name) ,
123+ Plugin :: Make ( plugin) => plugin. scan_exercise ( path, exercise_name) ,
124+ // the Java plugin is disabled on musl
125+ #[ cfg( not( target_env = "musl" ) ) ]
126+ Plugin :: Maven ( plugin) => plugin. scan_exercise ( path, exercise_name) ,
127+ Plugin :: NoTests ( plugin) => plugin. scan_exercise ( path, exercise_name) ,
128+ Plugin :: Python3 ( plugin) => plugin. scan_exercise ( path, exercise_name) ,
129+ Plugin :: R ( plugin) => plugin. scan_exercise ( path, exercise_name) ,
130+ // the Java plugin is disabled on musl
131+ #[ cfg( not( target_env = "musl" ) ) ]
132+ Plugin :: Ant ( plugin) => plugin. scan_exercise ( path, exercise_name) ,
133+ }
134+ }
135+
136+ pub fn run_tests ( & self , path : & Path ) -> Result < RunResult , TmcError > {
137+ match self {
138+ Plugin :: CSharp ( plugin) => plugin. run_tests ( path) ,
139+ Plugin :: Make ( plugin) => plugin. run_tests ( path) ,
140+ // the Java plugin is disabled on musl
141+ #[ cfg( not( target_env = "musl" ) ) ]
142+ Plugin :: Maven ( plugin) => plugin. run_tests ( path) ,
143+ Plugin :: NoTests ( plugin) => plugin. run_tests ( path) ,
144+ Plugin :: Python3 ( plugin) => plugin. run_tests ( path) ,
145+ Plugin :: R ( plugin) => plugin. run_tests ( path) ,
146+ // the Java plugin is disabled on musl
147+ #[ cfg( not( target_env = "musl" ) ) ]
148+ Plugin :: Ant ( plugin) => plugin. run_tests ( path) ,
149+ }
150+ }
151+
152+ pub fn check_code_style (
153+ & self ,
154+ path : & Path ,
155+ locale : Language ,
156+ ) -> Result < Option < StyleValidationResult > , TmcError > {
157+ match self {
158+ Plugin :: CSharp ( plugin) => plugin. check_code_style ( path, locale) ,
159+ Plugin :: Make ( plugin) => plugin. check_code_style ( path, locale) ,
160+ // the Java plugin is disabled on musl
161+ #[ cfg( not( target_env = "musl" ) ) ]
162+ Plugin :: Maven ( plugin) => plugin. check_code_style ( path, locale) ,
163+ Plugin :: NoTests ( plugin) => plugin. check_code_style ( path, locale) ,
164+ Plugin :: Python3 ( plugin) => plugin. check_code_style ( path, locale) ,
165+ Plugin :: R ( plugin) => plugin. check_code_style ( path, locale) ,
166+ // the Java plugin is disabled on musl
167+ #[ cfg( not( target_env = "musl" ) ) ]
168+ Plugin :: Ant ( plugin) => plugin. check_code_style ( path, locale) ,
169+ }
170+ }
95171}
96172
97173/// Allows calling LanguagePlugin functions without constructing the plugin.
98174#[ derive( Clone , Copy ) ]
99175pub enum PluginType {
100176 CSharp ,
101177 Make ,
178+ // the Java plugin is disabled on musl
179+ #[ cfg( not( target_env = "musl" ) ) ]
102180 Maven ,
103181 NoTests ,
104182 Python3 ,
105183 R ,
184+ // the Java plugin is disabled on musl
185+ #[ cfg( not( target_env = "musl" ) ) ]
106186 Ant ,
107187}
108188
@@ -111,10 +191,14 @@ macro_rules! delegate_plugin_type {
111191 match $self {
112192 Self :: CSharp => CSharpPlugin :: $( $args) * ,
113193 Self :: Make => MakePlugin :: $( $args) * ,
194+ // the Java plugin is disabled on musl
195+ #[ cfg( not( target_env = "musl" ) ) ]
114196 Self :: Maven => MavenPlugin :: $( $args) * ,
115197 Self :: NoTests => NoTestsPlugin :: $( $args) * ,
116198 Self :: Python3 => Python3Plugin :: $( $args) * ,
117199 Self :: R => RPlugin :: $( $args) * ,
200+ // the Java plugin is disabled on musl
201+ #[ cfg( not( target_env = "musl" ) ) ]
118202 Self :: Ant => AntPlugin :: $( $args) * ,
119203 }
120204 } ;
@@ -132,12 +216,18 @@ impl PluginType {
132216 ( Python3Plugin :: PLUGIN_NAME , PluginType :: Python3 )
133217 } else if RPlugin :: is_exercise_type_correct ( path) {
134218 ( RPlugin :: PLUGIN_NAME , PluginType :: R )
135- } else if MavenPlugin :: is_exercise_type_correct ( path) {
136- ( MavenPlugin :: PLUGIN_NAME , PluginType :: Maven )
137- } else if AntPlugin :: is_exercise_type_correct ( path) {
138- // TODO: currently, ant needs to be last because any project with src and test are recognized as ant
139- ( AntPlugin :: PLUGIN_NAME , PluginType :: Ant )
140219 } else {
220+ // the Java plugin is disabled on musl
221+ #[ cfg( not( target_env = "musl" ) ) ]
222+ if MavenPlugin :: is_exercise_type_correct ( path) {
223+ ( MavenPlugin :: PLUGIN_NAME , PluginType :: Maven )
224+ } else if AntPlugin :: is_exercise_type_correct ( path) {
225+ // TODO: currently, ant needs to be last because any project with src and test are recognized as ant
226+ ( AntPlugin :: PLUGIN_NAME , PluginType :: Ant )
227+ } else {
228+ return Err ( PluginError :: PluginNotFound ( path. to_path_buf ( ) ) ) ;
229+ }
230+ #[ cfg( target_env = "musl" ) ]
141231 return Err ( PluginError :: PluginNotFound ( path. to_path_buf ( ) ) ) ;
142232 } ;
143233 log:: info!( "Detected project at {} as {}" , path. display( ) , plugin_name) ;
@@ -155,12 +245,18 @@ impl PluginType {
155245 ( Python3Plugin :: PLUGIN_NAME , PluginType :: Python3 )
156246 } else if RPlugin :: is_archive_type_correct ( archive) {
157247 ( RPlugin :: PLUGIN_NAME , PluginType :: R )
158- } else if MavenPlugin :: is_archive_type_correct ( archive) {
159- ( MavenPlugin :: PLUGIN_NAME , PluginType :: Maven )
160- } else if AntPlugin :: is_archive_type_correct ( archive) {
161- // TODO: currently, ant needs to be last because any project with src and test are recognized as ant
162- ( AntPlugin :: PLUGIN_NAME , PluginType :: Ant )
163248 } else {
249+ // the Java plugin is disabled on musl
250+ #[ cfg( not( target_env = "musl" ) ) ]
251+ if MavenPlugin :: is_archive_type_correct ( archive) {
252+ ( MavenPlugin :: PLUGIN_NAME , PluginType :: Maven )
253+ } else if AntPlugin :: is_archive_type_correct ( archive) {
254+ // TODO: currently, ant needs to be last because any project with src and test are recognized as ant
255+ ( AntPlugin :: PLUGIN_NAME , PluginType :: Ant )
256+ } else {
257+ return Err ( PluginError :: PluginNotFoundInArchive ) ;
258+ }
259+ #[ cfg( target_env = "musl" ) ]
164260 return Err ( PluginError :: PluginNotFoundInArchive ) ;
165261 } ;
166262 log:: info!( "Detected project in archive as {}" , plugin_name) ;
@@ -222,9 +318,13 @@ pub fn get_student_file_policy(path: &Path) -> Result<Box<dyn StudentFilePolicy>
222318 path,
223319 ) ?) ,
224320 PluginType :: R => Box :: new ( <RPlugin as LanguagePlugin >:: StudentFilePolicy :: new ( path) ?) ,
321+ // the Java plugin is disabled on musl
322+ #[ cfg( not( target_env = "musl" ) ) ]
225323 PluginType :: Maven => Box :: new ( <MavenPlugin as LanguagePlugin >:: StudentFilePolicy :: new (
226324 path,
227325 ) ?) ,
326+ // the Java plugin is disabled on musl
327+ #[ cfg( not( target_env = "musl" ) ) ]
228328 PluginType :: Ant => Box :: new ( <AntPlugin as LanguagePlugin >:: StudentFilePolicy :: new ( path) ?) ,
229329 } ;
230330 Ok ( policy)
0 commit comments