{"id":18001460,"url":"https://github.com/egbakou/marathon-compilers","last_synced_at":"2025-03-26T08:30:47.391Z","repository":{"id":104621114,"uuid":"133258221","full_name":"egbakou/marathon-compilers","owner":"egbakou","description":"Compilation library for programming competitions. This library can be used to configure online compilers or to set up a platform for compiling and running programs during programming competitions.","archived":false,"fork":false,"pushed_at":"2018-06-02T14:36:23.000Z","size":100,"stargazers_count":3,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-21T11:50:36.376Z","etag":null,"topics":["compilers","interpreter","java-library","marathon","maven-plugin","shell","shell-extension","timing"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/egbakou.png","metadata":{"files":{"readme":"README.md","changelog":"Changelog.txt","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-05-13T17:12:44.000Z","updated_at":"2024-09-16T05:03:05.000Z","dependencies_parsed_at":null,"dependency_job_id":"7ef3e869-d8f5-424b-9f35-e61d16aee089","html_url":"https://github.com/egbakou/marathon-compilers","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/egbakou%2Fmarathon-compilers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/egbakou%2Fmarathon-compilers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/egbakou%2Fmarathon-compilers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/egbakou%2Fmarathon-compilers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/egbakou","download_url":"https://codeload.github.com/egbakou/marathon-compilers/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245618561,"owners_count":20645023,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["compilers","interpreter","java-library","marathon","maven-plugin","shell","shell-extension","timing"],"created_at":"2024-10-29T23:17:35.156Z","updated_at":"2025-03-26T08:30:47.378Z","avatar_url":"https://github.com/egbakou.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"Marathon Compilers\n==================\n### Continuous Integration\n[![Build Status](https://travis-ci.org/egbakou/marathon-compilers.svg?branch=master)](https://travis-ci.org/egbakou/marathon-compilers)\n\n### Quick Overview\nThis project was created to meet the need for compilation and execution of files during the programming contest we organized in [our university](http://www.iai-togo.com), a competition in which there was a web application with several compilers compiling and running the files of participants.\nThis project was based on the **zt-exec** project which allows to run external processes from **Java**. It provides several classes like **JavaCompiler, PythonCompiler, GccCompiler**, ... It is designed to be powerful but still easy to use.\n\n## Installation\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.egbakou/marathon-compilers/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.github.egbakou/marathon-compilers)\n\nThe project artifacts are available in [Maven Central Repository](https://search.maven.org/#search%7Cga%7C1%7Ccom.github.egbakou).\n\nTo include it in your maven project then you have to specify the dependency.\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.github.egbakou\u003c/groupId\u003e\n    \u003cartifactId\u003emarathon-compilers\u003c/artifactId\u003e\n    \u003cversion\u003e1.1\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n## Motivation\n\nThere are many approaches to take when running external processes from Java. There are the **JRE** options such as the **Runtime.exec()** and **ProcessBuilder**. Also there is the [Apache Commons Exec](http://commons.apache.org/proper/commons-exec/).  \n\nSome of the reasons for this library\n\n* Represent each compiler of the programming languages used by a class.\n* Return result after executing the uploded file\n * Reading/writing to streams\n * Redirecting stderr to stdout\n* Improved handling of timeouts\n* Improved checking of exit codes\n* Improved API\n * One liners for quite complex usecases\n * One liners to get process output into a String\n* Improved logging with [SLF4J API](http://www.slf4j.org/)\n* Support for multiple processes\n\n\n## Extension\nThis library can be used to configure online compilers or to set up a platform for compiling and running programs during programming competitions.\n\n## Download\nYou can download it by Git:\n\n    git clone https://github.com/egbakou/marathon-compilers.git\n\nor download the [archive](https://github.com/egbakou/marathon-compilers/archive/master.zip).\n\n## Requirements\nTo use this library, you must install:\n\n\t## =\u003eJava\n\tsudo apt-get install openjdk-8-jre openjdk-8-jdk\n\t## configure JAVA_HOME\n\t## Test installation: Main.java example\n  \tjavac Main.java \u0026\u0026 java Main \n  \t--------------------------------------------------\n  \t## =\u003ePython\n\tsudo apt-get install python3.6\n\t## Test installation: problem1.py example\n  \tpython problem1.py\n  \t--------------------------------------------------\n  \t## =\u003ePHP CLI\n  \tsudo apt-get install php5-cli\n  \t## Test installation: file.php example\n  \tphp file.php\n  \t--------------------------------------------------\n  \t## =\u003eFree Pascal\n  \tsudo apt-get install fp-compiler-3.0.2\n\t## Test installation: file.pass example\n\tfpc file.pass\n\t--------------------------------------------------\n\t## =\u003eC \u0026 C++ compiler\n\tsudo apt-get install build-essential\n\tgcc --version\n\tsudo apt-get install manpages-dev man-db manpages-posix-dev\n\tmake -v\n\t## Test installation: file.cpp example\n\tg++ file.cpp -o file\n\t--------------------------------------------------\n\t## =\u003eJavascript(nodejs)\n\tsudo apt-get  install nodejs\n\t## Test installation: file.js example\n\tnode file.js\n\t--------------------------------------------------\n\t## =\u003eC# compiler\n\tsudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF\n\techo \"deb https://download.mono-project.com/repo/ubuntu stable-bionic main\" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list\n\tsudo apt update\n\tsudo apt install mono-devel\n\t## Test installation: hello.cs example\n\tcsc hello.cs\n\t--------------------------------------------------\n\t## =\u003eKotlin\n\tcurl -s https://get.sdkman.io | bash\n\tsdk install kotlin\n\t## Test installation: Problem1.kt example\n  \tkotlinc Problem1.kt -include-runtime -d hello.jar\n  \tjava -jar Problem1.jar\n\nThis library also works on the Windows OS. For use on the Windows OS, install the equivalent compilers but provide the same compilation and execution commands as those in the example above. 😊\n\n**You can also install the compilers and interpreters that you need only.**\n\t\n## Example\n#### Java compiler\n* Compile and Run java file with timing constraints\n* Running with a timeout of 3 seconds\n```java\npublic static void main(String[] args) throws \nInterruptedException, IOException, TimeoutException {\n\n        String out = new JavaCompiler()\n                .directory(new File(\"/home/laurent/Documents\"))\n                .compileAndRunInTiming(\"Main.java\",TimeUnit.SECONDS,3L);\n\n        System.out.println(out);\n\n    }\n```\n\n* Compile java file without timing constraints (Runis not recommanded in competition contest; Read method documentation for details)\n\n```java\npublic static void main(String[] args) throws \nInterruptedException, IOException, TimeoutException {\n\n        String out = new JavaCompiler()\n                .directory(new File(\"/home/laurent/Documents\"))\n                .compileWithoutTiming(\"Main.java\");\n\n        System.out.println(out);\n\n    }\n```\n\n#### Python interpreter\n* Run PYTHON file with timing constraints\n* Running with a timeout of 3 seconds\n```java\npublic static void main(String[] args) throws \nInterruptedException, IOException, TimeoutException {\n\n\tString out = new PythonCompiler()\n                .directory(new File(\"/home/laurent/Documents\"))\n                .runInTiming(\"p001.py\",TimeUnit.SECONDS,3L);\n                \n\tSystem.out.println(out);\n\n    }\n```\n* Method *runWithoutTiming* is also avialable for PythonCompiler class.\n\n#### PHP interpreter\n* Run PHP file with timing constraints\n* Running with a timeout of 3 seconds\n```java\npublic static void main(String[] args) throws \nInterruptedException, IOException, TimeoutException {\n\n\tString out = new PhpCompiler()\n                .directory(new File(\"/home/laurent/Documents\"))\n                .runInTiming(\"euler1.php\",TimeUnit.SECONDS,3L);\n\n\tSystem.out.println(out);\n\n    }\n```\n* Method *runWithoutTiming* is also avialable for PhpCompiler class.\n\n#### JavaScript interpreter\n* Run Js file with timing constraints\n* Running with a timeout of 3 seconds\n```java\npublic static void main(String[] args) throws \nInterruptedException, IOException, TimeoutException {\n\n        String out = new JsCompiler()\n                .directory(new File(\"/home/laurent/Documents\"))\n                .runInTiming(\"index.js\",TimeUnit.SECONDS,3L);\n\n        System.out.println(out);\n\n    }\n```\n* Method *runWithoutTiming* is also avialable for JsCompiler class.\n\n#### C an C++ compiler\n* Compile and Run C or C++ file with timing constraints\n* Running with a timeout of 3 seconds\n```java\npublic static void main(String[] args) throws \nInterruptedException, IOException, TimeoutException {\n\n        String out = new GccCompiler()\n                .directory(new File(\"/home/laurent/Documents\"))\n                .compileAndRunInTiming(\"problem1.c\",TimeUnit.SECONDS,3L);\n\n        System.out.println(out);\n\n    }\n```\n* Method *compileAndRunWithoutTiming* is also avialable for GccCompiler class.\n\n#### Pascal compiler\n* Compile and Run file with timing constraints\n* Running with a timeout of 3 seconds\n```java\npublic static void main(String[] args) throws \nInterruptedException, IOException, TimeoutException {\n\n        String out = new PascalCompiler()\n                .directory(new File(\"/home/laurent/Documents\"))\n                .compileAndRunInTiming(\"euler1.pas\",TimeUnit.SECONDS,3L);\n\n        System.out.println(out);\n\n    }\n```\n* Method *compileAndRunWithoutTiming* is also avialable for PascalCompiler class.\n\n\n#### C# compiler\n* Compile and Run C# file with timing constraints\n* Running with a timeout of 3 seconds\n```java\npublic static void main(String[] args) throws \nInterruptedException, IOException, TimeoutException {\n\n        String out = new CSharpCompiler()\n                .directory(new File(\"/home/laurent/Documents\"))\n                .compileAndRunInTiming(\"euler1.cs\",TimeUnit.SECONDS,3L);\n\n        System.out.println(out);\n\n    }\n```\n* Method *compileAndRunWithoutTiming* is also avialable for CSharpCompiler class.\n\n#### Kotlin compiler\n* Compile and Run Kotlin file with timing constraints\n* Running with a timeout of 3 seconds\n```java\npublic static void main(String[] args) throws \nInterruptedException, IOException, TimeoutException {\n\n        String out = new KotlinCompiler()\n                .directory(new File(\"/home/laurent/Documents\"))\n                .compileAndRunInTiming(\"Problem001.kt\",TimeUnit.SECONDS,3L);\n\n        System.out.println(out);\n\n    }\n```\n* Method *compileAndRunWithoutTiming* is also avialable for KotlinCompiler class.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fegbakou%2Fmarathon-compilers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fegbakou%2Fmarathon-compilers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fegbakou%2Fmarathon-compilers/lists"}