Skip to content

Commit ce9685d

Browse files
Add a Gradle wrapper per exercise (#2657)
* Update root Gradle wrapper to 8.5 * Generate Gradle wrappers for each exercise * Add Gradle wrapper to exercise template * Add doc on how to update Gradle wrapper version * Remove Gradle from installation instructions * Update "Running the tests" page to use Gradle wrapper * Update contributing guide to use Gradle wrapper * Fix markdown lint error [no important files changed]
1 parent 1c80591 commit ce9685d

File tree

591 files changed

+50720
-259
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

591 files changed

+50720
-259
lines changed

.gitignore

-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,4 @@ resources/exercise-template/bin
2020
resources/exercise-template/.classpath
2121
resources/exercise-template/.project
2222
resources/exercise-template/.settings/
23-
resources/exercise-template/gradle/
24-
resources/exercise-template/gradlew
25-
resources/exercise-template/gradlew.bat
2623
*.class

CONTRIBUTING.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -82,19 +82,19 @@ After making changes to one or more exercises, make sure that they pass all vali
8282
#### Check whether the reference implementation passes the tests
8383

8484
```sh
85-
gradle test
85+
./gradlew test
8686
```
8787

8888
#### Check whether the reference implementation passes the Checkstyle validations
8989

9090
```sh
91-
gradle check
91+
./gradlew check
9292
```
9393

9494
#### Check whether the starter implementation is able to compile with the tests
9595

9696
```sh
97-
gradle compileStarterTestJava
97+
./gradlew compileStarterTestJava
9898
```
9999

100100
### Open a Pull Request

docs/INSTALLATION.md

+25-246
Original file line numberDiff line numberDiff line change
@@ -1,261 +1,40 @@
11
# Installing Java
22

3-
In addition to the exercism CLI and your favorite text editor, practicing with Exercism exercises in Java requires:
3+
In addition to the Exercism CLI and your favorite text editor,
4+
practicing with Exercism exercises in Java requires the **Java Development Kit** (JDK).
5+
The JDK includes both a Java Runtime _and_ development tools (most notably, the Java compiler).
46

5-
- the **Java Development Kit** (JDK) — which includes both a Java Runtime _and_ development tools (most notably, the Java compiler); and
6-
- **Gradle** — a build tool specifically for Java projects.
7+
There are many flavors of the JDK nowadays, some of which are open-source.
8+
Here at Exercism we recommend using [Eclipse Temurin by Adoptium][adoptium].
79

8-
Choose your operating system:
10+
## Supported Java versions
911

10-
- [Windows](#windows)
11-
- [macOS](#macos)
12-
- [Linux](#linux)
12+
Exercism's Java track supports Java 21 LTS and earlier.
1313

14-
... or ...
14+
## Installing Eclipse Temurin
1515

16-
- if you prefer to not use a package manager, you can [install manually](#install-manually).
16+
To install Eclipse Temurin on your system, head on over to their excellent [installation instructions][adoptium-installation-guide].
17+
Here you will find instructions on how to install the JDK using your favorite package manager,
18+
and it also contains links to downloadable installers for all major operating systems.
1719

18-
Optionally, you can also use a [Java IDE](#java-ides).
19-
20-
## Windows
21-
22-
Open an administrative command prompt. (If you need assistance opening an administrative prompt, see [open an elevated prompt in Windows 8+](http://www.howtogeek.com/194041/how-to-open-the-command-prompt-as-administrator-in-windows-8.1/) (or [Windows 7](http://www.howtogeek.com/howto/windows-vista/run-a-command-as-administrator-from-the-windows-vista-run-box/))).
23-
24-
1. If you have not installed Chocolatey, do so now:
25-
26-
```batchfile
27-
C:\Windows\system32> @powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin
28-
```
29-
30-
2. Install the JDK:
31-
32-
```batchfile
33-
C:\Windows\system32> choco install temurin21
34-
...
35-
C:\Windows\system32> refreshenv
36-
...
37-
```
38-
39-
3. Install Gradle:
40-
41-
```batchfile
42-
C:\Windows\system32>choco install gradle
43-
...
44-
```
45-
46-
We recommend closing the administrative command prompt and opening a new command prompt.
47-
You do not require administrator privileges to practice Exercism exercises.
48-
49-
You now are ready to get started with the Java track of Exercism!
50-
51-
To get started, see "[Running the Tests](https://exercism.org/docs/tracks/java/tests)".
52-
53-
## macOS
54-
55-
Below are instructions for install using the most common method - using Homebrew.
56-
If you'd rather, you can also [install on macOS without Homebrew](#installing-on-macos-without-homebrew).
57-
58-
## Installing
59-
60-
1. If you haven't installed [Homebrew](http://brew.sh), yet, do so now:
61-
62-
```sh
63-
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
64-
```
65-
66-
2. Tap the [Homebrew Cask](https://github.com/Homebrew/homebrew-cask-versions) — this allows us to install a specific JDK version.
67-
68-
```sh
69-
brew tap homebrew/cask-versions
70-
```
71-
72-
3. Install the JDK:
73-
74-
```sh
75-
brew install --cask temurin21
76-
```
77-
78-
4. Install Gradle:
79-
80-
```sh
81-
brew install gradle
82-
```
83-
84-
You now are ready to get started with the Java track of Exercism!
85-
86-
To get started, see "[Running the Tests](https://exercism.org/docs/tracks/java/tests)".
87-
88-
## Linux
89-
90-
Below are instructions for install using the package manager of your distro.
91-
If you'd rather, you can also [install on Linux without a package manager](#installing-on-linux-without-a-package-manager).
92-
93-
- [Debian](#debian)
94-
- [Other Linux distributions](#other-linux-distributions)
95-
96-
### Debian
97-
98-
If you are using Debian or its derivatives (like Ubuntu), use APT.
99-
100-
~~~~exercism/note
101-
These steps have been verified on Ubuntu 20.04 and 22.04
102-
~~~~
103-
104-
1. Install the JDK:
105-
106-
```sh
107-
sudo apt-get update
108-
sudo apt-get install software-properties-common
109-
sudo add-apt-repository ppa:openjdk-r/ppa
110-
sudo apt-get update
111-
sudo apt-get install openjdk-21-jdk
112-
```
113-
114-
2. Install Gradle:
115-
116-
```sh
117-
sudo add-apt-repository ppa:cwchien/gradle
118-
sudo apt-get update
119-
sudo apt-get install gradle
120-
```
121-
122-
You now are ready to get started with the Java track of Exercism!
123-
124-
To get started, see "[Running the Tests](https://exercism.org/docs/tracks/java/tests)".
125-
126-
### Other Linux distributions
127-
128-
There are a lot of ways to install JDK 21, but one of the easiest ways is to use SDKMAN, which lets you install
129-
both OpenJDK 21 and the latest Gradle with ease.
130-
131-
Use the following steps:
132-
133-
1. Install SDKMAN:
134-
135-
```sh
136-
curl -s "https://get.sdkman.io" | bash
137-
```
138-
139-
(if that doesn't work, take a look at the [installation instructions](https://sdkman.io/install))
140-
141-
2. Install OpenJDK 21:
142-
143-
```sh
144-
sdk install java 21.0.1-tem
145-
```
146-
147-
3. Install Gradle:
148-
149-
```sh
150-
sdk install gradle
151-
```
152-
153-
You now are ready to get started with the Java track of Exercism!
154-
155-
To get started, see "[Running the Tests](https://exercism.org/docs/tracks/java/tests)".
156-
157-
## Install Manually
158-
159-
- [Installing on Windows manually](#installing-on-windows-manually)
160-
- [Installing on macOS without Homebrew](#installing-on-macos-without-homebrew)
161-
- [Installing on Linux without a package manager](#installing-on-linux-without-a-package-manager)
162-
163-
### Installing on Windows manually
164-
165-
~~~~exercism/note
166-
These instructions are intended for experienced Windows users.
167-
If you don't already know how to set environment variables or feel comfortable managing the directory structure, we highly recommend you use the Chocolatey-based install, [above](#windows).
168-
~~~~
169-
170-
1. Install the JDK:
171-
- Download "**OpenJDK 21 (LTS)**" from [Adoptium](https://adoptium.net/temurin/releases/?os=windows&arch=x64&package=jdk&version=21) (choose **".msi"**).
172-
- Run the installer, using all the defaults.
173-
2. Install Gradle:
174-
- Download "**Binary only distribution**" from the [Gradle download page](https://gradle.org/gradle-download/).
175-
- Unzip the archive. We recommend a place like `C:\Users\JohnDoe\Tools`.
176-
- Add a new system environment variable named `GRADLE_HOME` and set it to the path you just created (e.g. `C:\Users\JohnDoe\Tools\gradle-x.y`).
177-
- Update the system `Path` to include the `bin` directory from Gradle's home (e.g. `Path`=`...;%GRADLE_HOME%\bin`).
178-
179-
You now are ready to get started with the Java track of Exercism!
180-
181-
To get started, see "[Running the Tests](https://exercism.org/docs/tracks/java/tests)".
182-
183-
### Installing on macOS without Homebrew
184-
185-
~~~~exercism/note
186-
These instructions are intended for experienced macOS users.
187-
Unless you specifically do not want to use a package manager, we highly recommend using the Homebrew-based installation instructions, [above](#macos).
188-
~~~~
189-
190-
1. Install the JDK:
191-
- Download "**OpenJDK 21 (LTS)**" from [Adoptium](https://adoptium.net/temurin/releases/?os=mac&package=jdk&version=21) (choose **".pkg"**).
192-
- Run the installer, using all the defaults.
193-
2. Install Gradle:
194-
195-
- Download "**Binary only distribution**" from the [Gradle download page](https://gradle.org/gradle-download/).
196-
- Unpack Gradle:
197-
198-
```sh
199-
mkdir ~/tools
200-
cd ~/tools
201-
unzip ~/Downloads/gradle-*-bin.zip
202-
cd gradle*
203-
```
204-
205-
- Configure Gradle and add it to the path:
206-
207-
```sh
208-
cat << DONE >> ~/.bashrc
209-
export GRADLE_HOME=`pwd`
210-
export PATH=\$PATH:\$GRADLE_HOME/bin
211-
DONE
212-
```
213-
214-
You now are ready to get started with the Java track of Exercism!
215-
216-
To get started, see "[Running the Tests](https://exercism.org/docs/tracks/java/tests)".
217-
218-
### Installing on Linux without a package manager
219-
220-
```exercism/note
221-
These instructions are intended for experienced Linux users.
222-
Unless you specifically do not want to use a package manager, we highly recommend using the installation instructions, [above](#linux).
223-
```
224-
225-
1. Install the JDK:
226-
- Choose your distribution and download "**OpenJDK 21 (LTS)**" from [Adoptium](https://adoptium.net/temurin/releases/?os=linux&package=jdk&version=21) (choose **".tar.gz"**).
227-
- Run the installer, using all the defaults.
228-
2. Install Gradle:
229-
230-
- Download "**Binary only distribution**" from the [Gradle download page](https://gradle.org/gradle-download/).
231-
- Unpack Gradle:
20+
## Java IDEs
23221

233-
```sh
234-
mkdir ~/tools
235-
cd ~/tools
236-
unzip ~/Downloads/gradle-*-bin.zip
237-
cd gradle*
238-
```
22+
There are many free IDEs available for Java.
23+
Here are some popular choices:
23924

240-
- Configure Gradle and add it to the path:
25+
- [IntelliJ IDEA Community Edition][intellij-idea]
26+
- [Eclipse][eclipse]
27+
- [Visual Studio Code with the Java extension][vscode-java]
24128

242-
```sh
243-
cat << DONE >> ~/.bashrc
244-
export GRADLE_HOME=`pwd`
245-
export PATH=\$PATH:\$GRADLE_HOME/bin
246-
DONE
247-
```
29+
## Next steps
24830

24931
You now are ready to get started with the Java track of Exercism!
25032

251-
To get started, see "[Running the Tests](https://exercism.org/docs/tracks/java/tests)".
252-
253-
## Java IDEs
254-
255-
There are many Java IDEs available. The three most popular are:
256-
257-
- [IntelliJ IDEA](https://www.jetbrains.com/idea/download/) (download the "Community" edition)
258-
- [Eclipse](https://www.eclipse.org/downloads/)
259-
- [NetBeans](https://netbeans.org/downloads/) (download the "Java SE" bundle)
33+
To get started, see "[Running the Tests][exercism-java-tests-docs]".
26034

261-
and there are [others](https://en.wikibooks.org/wiki/Java_Programming/Java_IDEs).
35+
[eclipse]: https://www.eclipse.org/downloads/
36+
[exercism-java-tests-docs]: https://exercism.org/docs/tracks/java/tests
37+
[intellij-idea]: https://www.jetbrains.com/idea/download/
38+
[adoptium]: https://adoptium.net
39+
[adoptium-installation-guide]: https://adoptium.net/en-GB/installation/
40+
[vscode-java]: https://code.visualstudio.com/docs/languages/java

docs/TESTS.md

+8-6
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ Choose your operating system:
2424
4. Run the tests:
2525

2626
```batchfile
27-
C:\Users\JohnDoe>gradle test
27+
C:\Users\JohnDoe>gradlew.bat test
2828
```
2929

3030
_(Don't worry about the tests failing, at first, this is how you begin each exercise.)_
3131

32-
5. Solve the exercise. Find and work through the `instructions.append.md` guide ([view on GitHub](https://github.com/exercism/java/blob/main/exercises/practice/hello-world/.docs/instructions.append.md#tutorial)).
32+
5. Solve the exercise. Find and work through the `instructions.append.md` guide ([view on GitHub][hello-world-tutorial]).
3333

3434
Good luck! Have fun!
3535

@@ -50,12 +50,12 @@ Good luck! Have fun!
5050
3. Run the tests:
5151

5252
```sh
53-
gradle test
53+
./gradlew test
5454
```
5555

5656
_(Don't worry about the tests failing, at first, this is how you begin each exercise.)_
5757

58-
4. Solve the exercise. Find and work through the `instructions.append.md` guide ([view on GitHub](https://github.com/exercism/java/blob/main/exercises/practice/hello-world/.docs/instructions.append.md#tutorial)).
58+
4. Solve the exercise. Find and work through the `instructions.append.md` guide ([view on GitHub][hello-world-tutorial]).
5959

6060
Good luck! Have fun!
6161

@@ -76,11 +76,13 @@ Good luck! Have fun!
7676
3. Run the tests:
7777

7878
```sh
79-
gradle test
79+
./gradlew test
8080
```
8181

8282
_(Don't worry about the tests failing, at first, this is how you begin each exercise.)_
8383

84-
4. Solve the exercise. Find and work through the `instructions.append.md` guide ([view on GitHub](https://github.com/exercism/java/blob/main/exercises/practice/hello-world/.docs/instructions.append.md#tutorial)).
84+
4. Solve the exercise. Find and work through the `instructions.append.md` guide ([view on GitHub][hello-world-tutorial]).
8585

8686
Good luck! Have fun!
87+
88+
[hello-world-tutorial]: https://github.com/exercism/java/blob/main/exercises/practice/hello-world/.docs/instructions.append.md#tutorial

exercises/build.gradle

+6
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ subprojects {
2929
if(project.name == 'concept' || project.name == 'practice')
3030
return
3131

32+
// Add a task that creates Gradle wrappers for all exercises,
33+
// matching the Gradle version of the project root.
34+
tasks.register('allWrappers', Wrapper) {
35+
gradleVersion = "$gradle.gradleVersion"
36+
}
37+
3238
sourceSets {
3339
// Set the directory containing the reference solution as the default source set. Default
3440
// compile tasks will now run against this source set.
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
4+
validateDistributionUrl=true
5+
zipStoreBase=GRADLE_USER_HOME
6+
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)