From 9e3e084c763935483e6917f9e30de63a2a9dfb42 Mon Sep 17 00:00:00 2001 From: chylex <contact@chylex.com> Date: Fri, 2 Dec 2022 23:34:23 +0100 Subject: [PATCH] Restructure project configuration (2021) --- .gitignore | 3 -- .idea/runConfigurations/2021___Day_01.xml | 11 ------- .idea/runConfigurations/2021___Day_02.xml | 11 ------- .idea/runConfigurations/2021___Day_03.xml | 11 ------- .idea/runConfigurations/2021___Day_04.xml | 11 ------- 2021/.gitignore | 5 +++ 2021/.idea/runConfigurations/Day_01.xml | 23 +++++++++++++ 2021/.idea/runConfigurations/Day_02.xml | 23 +++++++++++++ 2021/.idea/runConfigurations/Day_03.xml | 23 +++++++++++++ 2021/.idea/runConfigurations/Day_04.xml | 23 +++++++++++++ 2021/.idea/runConfigurations/Day_05.xml | 23 +++++++++++++ 2021/.idea/runConfigurations/Day_06.xml | 23 +++++++++++++ 2021/.idea/runConfigurations/Day_07.xml | 23 +++++++++++++ 2021/.idea/runConfigurations/Day_08.xml | 23 +++++++++++++ build.gradle.kts => 2021/build.gradle.kts | 31 ++++++++++-------- gradle.properties => 2021/gradle.properties | 0 .../gradle}/wrapper/gradle-wrapper.jar | Bin .../gradle}/wrapper/gradle-wrapper.properties | 0 gradlew => 2021/gradlew | 0 gradlew.bat => 2021/gradlew.bat | 0 2021/settings.gradle.kts | 1 + README.md | 4 ++- settings.gradle.kts | 1 - 23 files changed, 210 insertions(+), 63 deletions(-) delete mode 100644 .idea/runConfigurations/2021___Day_01.xml delete mode 100644 .idea/runConfigurations/2021___Day_02.xml delete mode 100644 .idea/runConfigurations/2021___Day_03.xml delete mode 100644 .idea/runConfigurations/2021___Day_04.xml create mode 100644 2021/.gitignore create mode 100644 2021/.idea/runConfigurations/Day_01.xml create mode 100644 2021/.idea/runConfigurations/Day_02.xml create mode 100644 2021/.idea/runConfigurations/Day_03.xml create mode 100644 2021/.idea/runConfigurations/Day_04.xml create mode 100644 2021/.idea/runConfigurations/Day_05.xml create mode 100644 2021/.idea/runConfigurations/Day_06.xml create mode 100644 2021/.idea/runConfigurations/Day_07.xml create mode 100644 2021/.idea/runConfigurations/Day_08.xml rename build.gradle.kts => 2021/build.gradle.kts (66%) rename gradle.properties => 2021/gradle.properties (100%) rename {gradle => 2021/gradle}/wrapper/gradle-wrapper.jar (100%) rename {gradle => 2021/gradle}/wrapper/gradle-wrapper.properties (100%) rename gradlew => 2021/gradlew (100%) rename gradlew.bat => 2021/gradlew.bat (100%) create mode 100644 2021/settings.gradle.kts delete mode 100644 settings.gradle.kts diff --git a/.gitignore b/.gitignore index ec32453..e811397 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,3 @@ -/.gradle/ -/build/ - /.idea/compiler.xml /.idea/dictionaries /.idea/encodings.xml diff --git a/.idea/runConfigurations/2021___Day_01.xml b/.idea/runConfigurations/2021___Day_01.xml deleted file mode 100644 index 8b7f694..0000000 --- a/.idea/runConfigurations/2021___Day_01.xml +++ /dev/null @@ -1,11 +0,0 @@ -<component name="ProjectRunConfigurationManager"> - <configuration default="false" name="2021 - Day 01" type="JetRunConfigurationType"> - <option name="MAIN_CLASS_NAME" value="MainKt" /> - <module name="Advent_of_Code.2021-01" /> - <shortenClasspath name="NONE" /> - <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/2021/01" /> - <method v="2"> - <option name="Make" enabled="true" /> - </method> - </configuration> -</component> \ No newline at end of file diff --git a/.idea/runConfigurations/2021___Day_02.xml b/.idea/runConfigurations/2021___Day_02.xml deleted file mode 100644 index 5d36df1..0000000 --- a/.idea/runConfigurations/2021___Day_02.xml +++ /dev/null @@ -1,11 +0,0 @@ -<component name="ProjectRunConfigurationManager"> - <configuration default="false" name="2021 - Day 02" type="JetRunConfigurationType"> - <option name="MAIN_CLASS_NAME" value="MainKt" /> - <module name="Advent_of_Code.2021-02" /> - <shortenClasspath name="NONE" /> - <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/2021/02" /> - <method v="2"> - <option name="Make" enabled="true" /> - </method> - </configuration> -</component> \ No newline at end of file diff --git a/.idea/runConfigurations/2021___Day_03.xml b/.idea/runConfigurations/2021___Day_03.xml deleted file mode 100644 index 06d565d..0000000 --- a/.idea/runConfigurations/2021___Day_03.xml +++ /dev/null @@ -1,11 +0,0 @@ -<component name="ProjectRunConfigurationManager"> - <configuration default="false" name="2021 - Day 03" type="JetRunConfigurationType"> - <option name="MAIN_CLASS_NAME" value="MainKt" /> - <module name="Advent_of_Code.2021-03" /> - <shortenClasspath name="NONE" /> - <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/2021/03" /> - <method v="2"> - <option name="Make" enabled="true" /> - </method> - </configuration> -</component> \ No newline at end of file diff --git a/.idea/runConfigurations/2021___Day_04.xml b/.idea/runConfigurations/2021___Day_04.xml deleted file mode 100644 index 26020cb..0000000 --- a/.idea/runConfigurations/2021___Day_04.xml +++ /dev/null @@ -1,11 +0,0 @@ -<component name="ProjectRunConfigurationManager"> - <configuration default="false" name="2021 - Day 04" type="JetRunConfigurationType"> - <option name="MAIN_CLASS_NAME" value="MainKt" /> - <module name="Advent_of_Code.2021-04" /> - <shortenClasspath name="NONE" /> - <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/2021/04" /> - <method v="2"> - <option name="Make" enabled="true" /> - </method> - </configuration> -</component> \ No newline at end of file diff --git a/2021/.gitignore b/2021/.gitignore new file mode 100644 index 0000000..5684d9f --- /dev/null +++ b/2021/.gitignore @@ -0,0 +1,5 @@ +/.idea/* +!/.idea/runConfigurations + +/.gradle/ +/build/ diff --git a/2021/.idea/runConfigurations/Day_01.xml b/2021/.idea/runConfigurations/Day_01.xml new file mode 100644 index 0000000..97e1bb7 --- /dev/null +++ b/2021/.idea/runConfigurations/Day_01.xml @@ -0,0 +1,23 @@ +<component name="ProjectRunConfigurationManager"> + <configuration default="false" name="Day 01" type="GradleRunConfiguration" factoryName="Gradle"> + <ExternalSystemSettings> + <option name="executionName" /> + <option name="externalProjectPath" value="$PROJECT_DIR$" /> + <option name="externalSystemIdString" value="GRADLE" /> + <option name="scriptParameters" value="--quiet" /> + <option name="taskDescriptions"> + <list /> + </option> + <option name="taskNames"> + <list> + <option value="01" /> + </list> + </option> + <option name="vmOptions" /> + </ExternalSystemSettings> + <ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess> + <ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess> + <DebugAllEnabled>false</DebugAllEnabled> + <method v="2" /> + </configuration> +</component> \ No newline at end of file diff --git a/2021/.idea/runConfigurations/Day_02.xml b/2021/.idea/runConfigurations/Day_02.xml new file mode 100644 index 0000000..939ba6b --- /dev/null +++ b/2021/.idea/runConfigurations/Day_02.xml @@ -0,0 +1,23 @@ +<component name="ProjectRunConfigurationManager"> + <configuration default="false" name="Day 02" type="GradleRunConfiguration" factoryName="Gradle"> + <ExternalSystemSettings> + <option name="executionName" /> + <option name="externalProjectPath" value="$PROJECT_DIR$" /> + <option name="externalSystemIdString" value="GRADLE" /> + <option name="scriptParameters" value="--quiet" /> + <option name="taskDescriptions"> + <list /> + </option> + <option name="taskNames"> + <list> + <option value="02" /> + </list> + </option> + <option name="vmOptions" /> + </ExternalSystemSettings> + <ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess> + <ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess> + <DebugAllEnabled>false</DebugAllEnabled> + <method v="2" /> + </configuration> +</component> \ No newline at end of file diff --git a/2021/.idea/runConfigurations/Day_03.xml b/2021/.idea/runConfigurations/Day_03.xml new file mode 100644 index 0000000..3144d0e --- /dev/null +++ b/2021/.idea/runConfigurations/Day_03.xml @@ -0,0 +1,23 @@ +<component name="ProjectRunConfigurationManager"> + <configuration default="false" name="Day 03" type="GradleRunConfiguration" factoryName="Gradle"> + <ExternalSystemSettings> + <option name="executionName" /> + <option name="externalProjectPath" value="$PROJECT_DIR$" /> + <option name="externalSystemIdString" value="GRADLE" /> + <option name="scriptParameters" value="--quiet" /> + <option name="taskDescriptions"> + <list /> + </option> + <option name="taskNames"> + <list> + <option value="03" /> + </list> + </option> + <option name="vmOptions" /> + </ExternalSystemSettings> + <ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess> + <ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess> + <DebugAllEnabled>false</DebugAllEnabled> + <method v="2" /> + </configuration> +</component> \ No newline at end of file diff --git a/2021/.idea/runConfigurations/Day_04.xml b/2021/.idea/runConfigurations/Day_04.xml new file mode 100644 index 0000000..86a54e5 --- /dev/null +++ b/2021/.idea/runConfigurations/Day_04.xml @@ -0,0 +1,23 @@ +<component name="ProjectRunConfigurationManager"> + <configuration default="false" name="Day 04" type="GradleRunConfiguration" factoryName="Gradle"> + <ExternalSystemSettings> + <option name="executionName" /> + <option name="externalProjectPath" value="$PROJECT_DIR$" /> + <option name="externalSystemIdString" value="GRADLE" /> + <option name="scriptParameters" value="--quiet" /> + <option name="taskDescriptions"> + <list /> + </option> + <option name="taskNames"> + <list> + <option value="04" /> + </list> + </option> + <option name="vmOptions" /> + </ExternalSystemSettings> + <ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess> + <ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess> + <DebugAllEnabled>false</DebugAllEnabled> + <method v="2" /> + </configuration> +</component> \ No newline at end of file diff --git a/2021/.idea/runConfigurations/Day_05.xml b/2021/.idea/runConfigurations/Day_05.xml new file mode 100644 index 0000000..813aad0 --- /dev/null +++ b/2021/.idea/runConfigurations/Day_05.xml @@ -0,0 +1,23 @@ +<component name="ProjectRunConfigurationManager"> + <configuration default="false" name="Day 05" type="GradleRunConfiguration" factoryName="Gradle"> + <ExternalSystemSettings> + <option name="executionName" /> + <option name="externalProjectPath" value="$PROJECT_DIR$" /> + <option name="externalSystemIdString" value="GRADLE" /> + <option name="scriptParameters" value="--quiet" /> + <option name="taskDescriptions"> + <list /> + </option> + <option name="taskNames"> + <list> + <option value="05" /> + </list> + </option> + <option name="vmOptions" /> + </ExternalSystemSettings> + <ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess> + <ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess> + <DebugAllEnabled>false</DebugAllEnabled> + <method v="2" /> + </configuration> +</component> \ No newline at end of file diff --git a/2021/.idea/runConfigurations/Day_06.xml b/2021/.idea/runConfigurations/Day_06.xml new file mode 100644 index 0000000..ed4fdc7 --- /dev/null +++ b/2021/.idea/runConfigurations/Day_06.xml @@ -0,0 +1,23 @@ +<component name="ProjectRunConfigurationManager"> + <configuration default="false" name="Day 06" type="GradleRunConfiguration" factoryName="Gradle"> + <ExternalSystemSettings> + <option name="executionName" /> + <option name="externalProjectPath" value="$PROJECT_DIR$" /> + <option name="externalSystemIdString" value="GRADLE" /> + <option name="scriptParameters" value="--quiet" /> + <option name="taskDescriptions"> + <list /> + </option> + <option name="taskNames"> + <list> + <option value="06" /> + </list> + </option> + <option name="vmOptions" /> + </ExternalSystemSettings> + <ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess> + <ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess> + <DebugAllEnabled>false</DebugAllEnabled> + <method v="2" /> + </configuration> +</component> \ No newline at end of file diff --git a/2021/.idea/runConfigurations/Day_07.xml b/2021/.idea/runConfigurations/Day_07.xml new file mode 100644 index 0000000..accdc81 --- /dev/null +++ b/2021/.idea/runConfigurations/Day_07.xml @@ -0,0 +1,23 @@ +<component name="ProjectRunConfigurationManager"> + <configuration default="false" name="Day 07" type="GradleRunConfiguration" factoryName="Gradle"> + <ExternalSystemSettings> + <option name="executionName" /> + <option name="externalProjectPath" value="$PROJECT_DIR$" /> + <option name="externalSystemIdString" value="GRADLE" /> + <option name="scriptParameters" value="--quiet" /> + <option name="taskDescriptions"> + <list /> + </option> + <option name="taskNames"> + <list> + <option value="07" /> + </list> + </option> + <option name="vmOptions" /> + </ExternalSystemSettings> + <ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess> + <ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess> + <DebugAllEnabled>false</DebugAllEnabled> + <method v="2" /> + </configuration> +</component> \ No newline at end of file diff --git a/2021/.idea/runConfigurations/Day_08.xml b/2021/.idea/runConfigurations/Day_08.xml new file mode 100644 index 0000000..daca41e --- /dev/null +++ b/2021/.idea/runConfigurations/Day_08.xml @@ -0,0 +1,23 @@ +<component name="ProjectRunConfigurationManager"> + <configuration default="false" name="Day 08" type="GradleRunConfiguration" factoryName="Gradle"> + <ExternalSystemSettings> + <option name="executionName" /> + <option name="externalProjectPath" value="$PROJECT_DIR$" /> + <option name="externalSystemIdString" value="GRADLE" /> + <option name="scriptParameters" value="--quiet" /> + <option name="taskDescriptions"> + <list /> + </option> + <option name="taskNames"> + <list> + <option value="08" /> + </list> + </option> + <option name="vmOptions" /> + </ExternalSystemSettings> + <ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess> + <ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess> + <DebugAllEnabled>false</DebugAllEnabled> + <method v="2" /> + </configuration> +</component> \ No newline at end of file diff --git a/build.gradle.kts b/2021/build.gradle.kts similarity index 66% rename from build.gradle.kts rename to 2021/build.gradle.kts index b803edb..549e684 100644 --- a/build.gradle.kts +++ b/2021/build.gradle.kts @@ -1,10 +1,12 @@ +@file:Suppress("ConvertLambdaToReference") + plugins { kotlin("jvm") version "1.6.0" idea } group = "com.chylex.adventofcode" -version = "1.0-SNAPSHOT" +version = "1.0" repositories { mavenCentral() @@ -19,16 +21,14 @@ idea { file(".gradle"), file("build"), file("gradle"), - file("2015"), - file("2020") )) } sourceSets { - fun make(year: Int, day: Int) { + fun make(day: Int) { val paddedDay = day.toString().padStart(2, '0') - val sourceFolder = file("$year/$paddedDay") + val sourceFolder = file(paddedDay) val resourceFolder = sourceFolder.resolve("input") if (!sourceFolder.exists()) { @@ -38,18 +38,21 @@ sourceSets { resourceFolder.resolve("1.txt").writeText("") } - create("$year-$paddedDay") { + create(paddedDay) { java.setSrcDirs(listOf(sourceFolder)) resources.setSrcDirs(listOf(resourceFolder)) } + + tasks.register<JavaExec>(paddedDay) { + group = "run" + + mainClass.set("MainKt") + workingDir = sourceFolder + classpath = sourceSets[paddedDay].runtimeClasspath + } } - make(2021, 1) - make(2021, 2) - make(2021, 3) - make(2021, 4) - make(2021, 5) - make(2021, 6) - make(2021, 7) - make(2021, 8) + for (day in 1..8) { + make(day) + } } diff --git a/gradle.properties b/2021/gradle.properties similarity index 100% rename from gradle.properties rename to 2021/gradle.properties diff --git a/gradle/wrapper/gradle-wrapper.jar b/2021/gradle/wrapper/gradle-wrapper.jar similarity index 100% rename from gradle/wrapper/gradle-wrapper.jar rename to 2021/gradle/wrapper/gradle-wrapper.jar diff --git a/gradle/wrapper/gradle-wrapper.properties b/2021/gradle/wrapper/gradle-wrapper.properties similarity index 100% rename from gradle/wrapper/gradle-wrapper.properties rename to 2021/gradle/wrapper/gradle-wrapper.properties diff --git a/gradlew b/2021/gradlew similarity index 100% rename from gradlew rename to 2021/gradlew diff --git a/gradlew.bat b/2021/gradlew.bat similarity index 100% rename from gradlew.bat rename to 2021/gradlew.bat diff --git a/2021/settings.gradle.kts b/2021/settings.gradle.kts new file mode 100644 index 0000000..bfebbe4 --- /dev/null +++ b/2021/settings.gradle.kts @@ -0,0 +1 @@ +rootProject.name = "2021" diff --git a/README.md b/README.md index 4829cf0..9a4923c 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,9 @@ I have included Run Configurations for JetBrains IDEs, so if you use the appropr ## \[2021\] Kotlin -The repository contains a Gradle project (`build.gradle.kts`) that sets up every day as a module. You should be able to load the Gradle project into [IntelliJ IDEA](https://www.jetbrains.com/idea/). +The repository contains a Gradle project (`2021/build.gradle.kts`) that sets up every day as a source root and a task that can be launched with `gradlew <day>`, for ex. `gradlew 01`. + +You should be able to load the Gradle project into [IntelliJ IDEA](https://www.jetbrains.com/idea/). The source code is in `main.kt`. The run configuration executes the `main()` method in this file. diff --git a/settings.gradle.kts b/settings.gradle.kts deleted file mode 100644 index f4535c0..0000000 --- a/settings.gradle.kts +++ /dev/null @@ -1 +0,0 @@ -rootProject.name = "Advent of Code"