{"id":24413918,"url":"https://github.com/cinaq/mendix-userlib-cleaner","last_synced_at":"2025-04-12T03:40:41.372Z","repository":{"id":64306507,"uuid":"408078443","full_name":"cinaq/mendix-userlib-cleaner","owner":"cinaq","description":"A simple CLI tool that identifies duplicate JARS in a directory. It can remove them also if desired.","archived":false,"fork":false,"pushed_at":"2024-11-08T06:25:02.000Z","size":19765,"stargazers_count":22,"open_issues_count":4,"forks_count":5,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-03-25T23:12:58.784Z","etag":null,"topics":["conflict-resolution","developer-tools","java","mendix"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cinaq.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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":"2021-09-19T08:57:44.000Z","updated_at":"2024-11-21T22:24:39.000Z","dependencies_parsed_at":"2024-11-08T07:28:19.675Z","dependency_job_id":null,"html_url":"https://github.com/cinaq/mendix-userlib-cleaner","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cinaq%2Fmendix-userlib-cleaner","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cinaq%2Fmendix-userlib-cleaner/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cinaq%2Fmendix-userlib-cleaner/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cinaq%2Fmendix-userlib-cleaner/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cinaq","download_url":"https://codeload.github.com/cinaq/mendix-userlib-cleaner/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248514233,"owners_count":21116899,"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":["conflict-resolution","developer-tools","java","mendix"],"created_at":"2025-01-20T07:16:21.061Z","updated_at":"2025-04-12T03:40:41.344Z","avatar_url":"https://github.com/cinaq.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Mendix Userlib Cleaner\n\nThis little utility can be used to identify and clean duplicate JARs. It was created mainly for [Mendix](https://mendix.com) apps due to lack of formal dependency management support. This is by no means limited to Mendix use-case. It works for arbitary systems.\n\nPlease note that this is not a magic tool that solves all JAR problems. After running the clean tool, always clean your project, rebuild and run it locally.\n\n## In rush?\n\n- Download the windows build from [release](https://github.com/cinaq/mendix-userlib-cleaner/releases)\n- Unzip the `mendix-userlib-cleaner.exe` into your userlib you want to clean\n- In Explorer window location write `cmd` and press enter. This opens a black terminal window\n- In this terminal window write: `.\\mendix-userlib-cleaner.exe`\n- It should inform you what it will remove. Verify the output and to actually remove the jars write: `.\\mendix-userlib-cleaner.exe --clean`\n\n## Why clean userlib?\n\nMost Mendix modules include one or more JAR files. JAR files are java libraries. This is a common approach to extend functionalities in Mendix apps. However as your application ages and grows there's a need to add more modules or update existing ones which introduces newer versions. These JAR's are not managed by Mendix Studio. Due to these dynamics, newer JAR can be introduced at later stage. This causes duplication. Due to JAR duplication it often causes compatibility issues. If you are lucky these errors occur during compile time. At other times these occur during runtime.\n\n## How does this work?\n\nIt works as follow:\n\n- list all the JAR files\n- for each JAR file compute its properties by extracting `MANIFEST.MF` or `pom.properties` from the JAR file\n- Next we loop over the metadata and determine which JAR to keep and discard duplicates. This is done based on the package name (e.g. org.package.velocity) and the version (e.g. 1.7)\n- Those marked to be discarded are then removed.\n\nNote that `mode` now also accepts path to `m2ee-log.txt`. This file can be obtained when you run your app locally in **Mendix Studio Pro**.\n\n## Usage\n\n```bash\nmendix-userlib-cleaner --help\nUsage of mendix-userlib-cleaner:\n      --clean           Turn on to actually remove the duplicate JARs.\n      --mode string     Jar parsing mode. Supported options: auto, strict or path to m2ee-log.txt (default \"auto\")\n      --target string   Path to userlib. (default \".\")\n      --verbose         Turn on to see debug information.\npflag: help requested\n\n\n$ mendix-userlib-cleaner --target ~/resources/jars\n01:06:03.237 listAllFiles ▶ INFO 001 Listing all files in target directory: ./resources/jars\n01:06:03.237 listAllJars ▶ INFO 002 Finding and parsing JARs\n01:06:03.237 listAllJars ▶ DEBU 003 Processing JAR: resources/jars/activation-1.1.1.jar\n01:06:03.238 getJarProps ▶ DEBU 004 Parsed properties from MANIFEST: {1.1.1 1001001 resources/jars/activation-1.1.1.jar activation-1.1.1.jar Sun Java System Application Server Sun Java System Application Server Sun Microsystems, Inc. }\n01:06:03.238 listAllJars ▶ DEBU 005 Processing JAR: resources/jars/checker-qual-2.5.2.jar\n01:06:03.241 getJarProps ▶ DEBU 006 Parsed properties optimistically: {2.5.2 2005002 resources/jars/checker-qual-2.5.2.jar checker-qual-2.5.2.jar org.checkerframework.dataflow   }\n01:06:03.241 listAllJars ▶ DEBU 007 Processing JAR: resources/jars/checker-qual-2.5.3.jar\n01:06:03.243 getJarProps ▶ DEBU 008 Parsed properties optimistically: {2.5.3 2005003 resources/jars/checker-qual-2.5.3.jar checker-qual-2.5.3.jar org.checkerframework.dataflow   }\n01:06:03.243 listAllJars ▶ DEBU 009 Processing JAR: resources/jars/junit-4.11.jar\n01:06:03.252 getJarProps ▶ DEBU 00a Parsed properties optimistically: {4.11 4011 resources/jars/junit-4.11.jar junit-4.11.jar org.junit   }\n01:06:03.252 listAllJars ▶ DEBU 00b Processing JAR: resources/jars/kafka-streams-2.4.0.jar\n01:06:03.257 getJarProps ▶ DEBU 00c Parsed properties optimistically: {2.4.0 2004000 resources/jars/kafka-streams-2.4.0.jar kafka-streams-2.4.0.jar org.apache.kafka   }\n01:06:03.257 listAllJars ▶ DEBU 00d Processing JAR: resources/jars/xmlbeans-3.1.0.jar\n01:06:03.263 getJarProps ▶ DEBU 00e Parsed properties from MANIFEST: {3.1.0 3001000 resources/jars/xmlbeans-3.1.0.jar xmlbeans-3.1.0.jar org.apache.xmlbeans org.apache.xmlbeans Apache Software Foundation }\n01:06:03.263 computeJarsToKeep ▶ INFO 00f Computing duplicates\n01:06:03.263 computeJarsToKeep ▶ INFO 010 Found newer checker-qual-2.5.3.jar over checker-qual-2.5.2.jar\n01:06:03.263 cleanJars ▶ INFO 011 Cleaning...\n01:06:03.263 cleanJars ▶ DEBU 012 Keeping jar: {1.1.1 1001001 resources/jars/activation-1.1.1.jar activation-1.1.1.jar Sun Java System Application Server Sun Java System Application Server Sun Microsystems, Inc. }\n01:06:03.263 cleanJars ▶ WARN 013 Would remove file org.checkerframework.dataflow: resources/jars/checker-qual-2.5.2.jar\n01:06:03.263 cleanJars ▶ WARN 014 Would remove file org.checkerframework.dataflow: resources/jars/checker-qual-2.5.2.jar.meta\n01:06:03.263 cleanJars ▶ DEBU 015 Keeping jar: {2.5.3 2005003 resources/jars/checker-qual-2.5.3.jar checker-qual-2.5.3.jar org.checkerframework.dataflow   }\n01:06:03.263 cleanJars ▶ DEBU 016 Keeping jar: {4.11 4011 resources/jars/junit-4.11.jar junit-4.11.jar org.junit   }\n01:06:03.263 cleanJars ▶ DEBU 017 Keeping jar: {2.4.0 2004000 resources/jars/kafka-streams-2.4.0.jar kafka-streams-2.4.0.jar org.apache.kafka   }\n01:06:03.263 cleanJars ▶ DEBU 018 Keeping jar: {3.1.0 3001000 resources/jars/xmlbeans-3.1.0.jar xmlbeans-3.1.0.jar org.apache.xmlbeans org.apache.xmlbeans Apache Software Foundation }\n01:06:03.263 cleanJars ▶ INFO 019 Clean up 1 jars and 1 meta files\n01:06:03.263 main ▶ INFO 01a Would have removed: 2 files\n01:06:03.263 main ▶ INFO 01b Use --clean to actually remove above file(s)\n```\n\n## Extracting metadata\n\n### jar format 1\n\n```\n$ cat META-INF/maven/com.sun.istack/istack-commons-runtime/pom.properties\n#Created by Apache Maven 3.5.4\ngroupId=com.sun.istack\nartifactId=istack-commons-runtime\nversion=3.0.8\n```\n\n### jar format 2\n\n```\n$ cat META-INF/MANIFEST.MF\nManifest-Version: 1.0\nAnt-Version: Apache Ant 1.7.0\nCreated-By: Apache Ant\nPackage: org.apache.velocity\nBuild-Jdk: 1.4.2_16\nExtension-Name: velocity\nSpecification-Title: Velocity is a Java-based template engine\nSpecification-Vendor: Apache Software Foundation\nImplementation-Title: org.apache.velocity\nImplementation-Vendor-Id: org.apache\nImplementation-Vendor: Apache Software Foundation\nImplementation-Version: 1.7\nBundle-ManifestVersion: 2\nBundle-Name: Apache Velocity\nBundle-Vendor: Apache Software Foundation\nBundle-SymbolicName: org.apache.velocity\nBundle-Version: 1.7\n```\n\n### jar format 3\n\n```\n$ cat META-INF/MANIFEST.MF\nManifest-Version: 1.0\nExport-Package: com.google.gson;version=2.2.4, com.google.gson.annotat\n ions;version=2.2.4, com.google.gson.reflect;version=2.2.4, com.google\n .gson.stream;version=2.2.4, com.google.gson.internal;version=2.2.4, c\n om.google.gson.internal.bind;version=2.2.4\nBundle-ClassPath: .\nBuilt-By: inder\nBundle-Name: Gson\nCreated-By: Apache Maven 3.0.4\nBundle-RequiredExecutionEnvironment: J2SE-1.5\nBundle-Vendor: Google Gson Project\nBundle-ContactAddress: http://code.google.com/p/google-gson/\nBundle-Version: 2.2.4\nBuild-Jdk: 1.7.0_21\nBundle-ManifestVersion: 2\nBundle-Description: Google Gson library\nBundle-SymbolicName: com.google.gson\nArchiver-Version: Plexus Archiver\n```\n\n### File name parsing\n\nWhen no usable metadata is found in the manifest or POM files, we try to parse the filename itself to determine the package name and version. For example:\n\n```\neventTrackingLibrary-1.0.2.jar -\u003e local.eventtracking\n```\n\nAnd version would be `1.0.2`.\n\n\n### Optimistic parsing\n\nSometimes there is no usable metadata included in the package. In that case we try to compose the package name by finding the first class file in the jar of which resides in the directory `org` or `com`. e.g. `org.junit`\n\n\n\n## License\n\nSee the [LICENSE](LICENSE.md) file for license rights and limitations (MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcinaq%2Fmendix-userlib-cleaner","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcinaq%2Fmendix-userlib-cleaner","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcinaq%2Fmendix-userlib-cleaner/lists"}