diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..7e10cd8 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,47 @@ +name: ๐Ÿ”จ Build and Check PR ๐Ÿš€ + +on: + pull_request: + branches: + - main + push: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + + steps: + # Step 1: Checkout the repository ๐Ÿ“‚ + - name: ๐Ÿ“ฅ Checkout repository + uses: actions/checkout@v4 + + # Step 2: Set up Zulu JDK 17 โ˜• + - name: โ˜• Set up Zulu JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' # Set the desired JDK version + distribution: 'zulu' # Specify Zulu as the distribution + + # Step 3: Build the project ๐Ÿ”จ + - name: ๐Ÿ”จ Run Gradle build + run: ./gradlew build --no-daemon + + # Step 4: Create the shadow JAR ๐Ÿ“ฆ + - name: ๐Ÿ› ๏ธ Build Shadow JAR + run: ./gradlew shadowJar --no-daemon + + # Step 5: Get the name of the generated jar file + - name: ๐Ÿงพ Get the shadowJar file name + id: get_jar_name + run: | + JAR_NAME=$(basename build/libs/*.jar) + echo "jar_name=$JAR_NAME" >> $GITHUB_ENV + + # Step 6: Upload the shadowJar artifact (optional) ๐ŸŽ + - name: ๐ŸŽ Upload shadowJar + uses: actions/upload-artifact@v4 + with: + name: ${{ env.jar_name }} + path: build/libs/${{ env.jar_name }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..fb0e662 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,79 @@ +name: ๐Ÿš€โœจ Create Fun Release with JAR Upload ๐ŸŽ‰ + +on: + push: + tags: + - 'v*' # Trigger on version tag pushes (e.g., v1.0, v2.0) + +jobs: + build: + runs-on: ubuntu-latest + + steps: + # Step 1: Checkout the repository ๐Ÿ›Ž๏ธ + - name: ๐Ÿ›Ž๏ธ๐Ÿ” Checkout code + uses: actions/checkout@v4 + + # Step 2: Set up JDK 17 (using Zulu) โ˜• + - name: โ˜•๐Ÿง™โ€โ™‚๏ธ Set up Zulu JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'zulu' + + # Step 3: Build the project and create shadowJar ๐Ÿ—๏ธ + - name: ๐Ÿ—๏ธโœจ Build with Gradle and Create shadowJar + run: ./gradlew shadowJar --no-daemon + + # Step 4: Get the JAR file name ๐Ÿ“ + - name: ๐Ÿ“๐Ÿ” Get JAR file name + id: jar-name + run: | + JAR_FILE=$(ls build/libs/*.jar) + echo "jar_file=$JAR_FILE" >> $GITHUB_ENV + + # Step 5: Create a new release ๐Ÿ“ฆ + - name: ๐Ÿ“ฆ๐ŸŽ‰ Create GitHub Release + id: create_release + uses: actions/github-script@v7 + with: + script: | + const { promises: fs } = require('fs'); + + // Get the latest tag + const tag = context.ref.replace('refs/tags/', ''); + + // Read the release notes if available + const releaseNotes = await fs.readFile('CHANGELOG.md', 'utf-8').catch(() => 'No release notes.'); + + // Create the release + const release = await github.rest.repos.createRelease({ + owner: context.repo.owner, + repo: context.repo.repo, + tag_name: tag, + name: tag, + body: releaseNotes, + draft: false, + prerelease: false, + }); + + core.setOutput('release_id', release.data.id); + + # Step 6: Download and install `ghr` tool ๐Ÿ”ง + - name: ๐Ÿ”งโšก Download and Install ghr tool + run: | + GHR_VERSION="v0.16.2" # Specify the version you want to install + wget https://github.com/tcnksm/ghr/releases/download/$GHR_VERSION/ghr_${GHR_VERSION}_linux_amd64.tar.gz + tar -xzf ghr_${GHR_VERSION}_linux_amd64.tar.gz + sudo mv ghr_${GHR_VERSION}_linux_amd64/ghr /usr/local/bin/ + ghr --version + + # Step 7: Upload the JAR to the release ๐Ÿ—๏ธ๐Ÿ“ฆ + - name: ๐Ÿš€๐Ÿ“ฆ Upload JAR to GitHub Release + run: | + ghr -u "${GITHUB_REPOSITORY%/*}" \ + -r "${GITHUB_REPOSITORY#*/}" \ + "${GITHUB_REF#refs/tags/}" \ + "${{ env.jar_file }}" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..9b4328d --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,26 @@ +# Changelog + +## [Version 1.0] + +### Added +- Flag-based operations for **find** and **delete** functionalities, allowing users to specify operations more clearly using command-line flags. + +### Changed +- Organized the project structure using **Gradle**, making it easier to manage dependencies and build processes. + +### Updated +- Integrated JAR file usage for executing the application, simplifying the running process for users. + +### Removed +- Manual compilation steps are no longer required, enhancing user experience and reducing setup complexity. + +### Examples +- **Find duplicates**: + ```bash + java -jar search-and-delete-duplicates-1.0-SNAPSHOT.jar --find [...] + ``` + +- **Delete files**: + ```bash + java -jar search-and-delete-duplicates-1.0-SNAPSHOT.jar --delete + ``` \ No newline at end of file diff --git a/README.md b/README.md index fdea04f..c4358c4 100644 --- a/README.md +++ b/README.md @@ -1,51 +1,81 @@ Search-and-Delete-duplicate-files ================================= - Prerequisites: - 1. JDK must be installed, and - 2. Path environments must be set. +This tool scans specified directories for duplicate files, automatically excluding common project and system directories. It helps users reclaim disk space by identifying and removing redundant files with ease. -How to use this? +## Prerequisites - Follow the steps to use it: - Step 1: Clone the repo - Step 2: Open `Terminal` or `Command Prompt` - Step 3: Navigate to the cloned repo - Step 4: Compile code `javac *.java` - Step 5: Run `java ListFiles ` - Step 6: After processing is completed a file will be generated with list of - duplicate files. Open the file and REMOVE THE ENTRIES WHICH YOU WANT TO KEEP. - Step 7: Run 'java Deletion ` +1. **JDK 17** must be installed. +2. Path environments must be set. -Now it will delete all those files listed in `toDelete` file. +## How to use this - NOTE: - 1. File once deleted cannot be recovered. They will be deleted permanently. - So, be careful while using `Deletion`. - 2. Whenever you want to escape press +c [^c] to exit. +Follow the steps to use it: -Java source code to search a directory, recursively, for duplicate files. Well, this code is not commented, but feel -free to query. +1. Download the JAR file: `search-and-delete-duplicates-1.0-SNAPSHOT.jar`. +2. Open `Terminal` or `Command Prompt`. +3. Run the command to find duplicates: + ```shell + java -jar search-and-delete-duplicates-1.0-SNAPSHOT.jar --find + ``` +4. After processing is completed, a file will be generated with a list of duplicate files. Open the file and REMOVE THE ENTRIES WHICH YOU WANT TO KEEP. +5. To delete the files listed in the `toDelete` file, run: + ```shell + java -jar search-and-delete-duplicates-1.0-SNAPSHOT.jar --delete + ``` -Feel free to reorganize code, and distribute your own version. I would be happy if you could state your name and -application, in which this code is used. +## Usage +```shell +java -jar search-and-delete-duplicates-1.0-SNAPSHOT.jar --find [...] +java -jar search-and-delete-duplicates-1.0-SNAPSHOT.jar --delete +``` -Send email with following details: +## Examples +```shell +java -jar search-and-delete-duplicates-1.0-SNAPSHOT.jar --find ~/dir1 ~/dir2 +java -jar search-and-delete-duplicates-1.0-SNAPSHOT.jar --delete toDelete.txt +``` - To: krishna[at]pcsalt[dot]com - Subject: [Search-and-Delete-duplicate-files] - Message: [Name] [Application-Name] +## NOTE +1. File once deleted cannot be recovered. They will be deleted permanently. So, be careful while using `Deletion`. +2. Whenever you want to escape, press `+c` [^c] to exit. + +## Ignored Directories and Files + +When the program searches for duplicate files, it ignores specific directories and files to streamline the process and avoid unnecessary scanning of commonly used directories. + +### Ignored Directories +The following directories are excluded from the search: +- **.git**: This directory is used for version control by Git, and its contents are not relevant to duplicate file searching. +- **build**: This directory often contains compiled files generated during the build process, which are not considered duplicates. +- **node_modules**: This directory is used by Node.js projects to store dependencies and is typically large, so it is ignored. +- **.gradle**: This directory contains Gradle-specific files and caches, which do not need to be scanned. +- **.idea**: This directory is used by JetBrains IDEs (like IntelliJ IDEA) to store project-specific settings and configurations. + +### Ignored Files +The program also ignores the following file: +- **.DS_Store**: This is a file created by macOS to store custom attributes of a folder, and it is not useful for the duplicate file search. + +By excluding these directories and files, the program focuses on relevant files, enhancing performance and accuracy. + +Feel free to reorganize the code and distribute your own version. I would be happy if you could state your name and application in which this code is used. + +Send email with the following details: + +- **To:** krishna[at]pcsalt[dot]com +- **Subject:** [Search-and-Delete-duplicate-files] +- **Message:** [your-text] Thank you. - Copyright 2014 Krrishnaaaa - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. +## License +Copyright 2014 Krrishnaaaa + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at +[Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0) +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and limitations under the License. \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index de8e05e..2976bf4 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -38,4 +38,16 @@ tasks { archiveClassifier.set("") archiveVersion.set("1.0-SNAPSHOT") } +} + +tasks.named("startShadowScripts") { + dependsOn(tasks.named("jar")) +} + +tasks.named("startScripts") { + dependsOn(tasks.named("shadowJar")) +} + +tasks.named("distTar") { + dependsOn(tasks.named("shadowJar")) } \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..a4b76b9 Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ