Artifactory无法识别已添加至Jar包的自定义许可证问题
Since manual Search Archive License File works, the issue is almost certainly tied to how Artifactory's automated scanning pipeline is configured or triggered—not the license file itself. Let’s walk through the most likely fixes step by step:
Verify automatic scan triggers and repository settings
Double-check that your target repository hasEnable Automatic License Scanningturned on (under Repository Configuration > Advanced). Also, note that auto-scans often only run on newly deployed artifacts—if you uploaded the jar before configuring the custom license type, you’ll need to manually trigger a rescan for that specific artifact (right-click the jar > Actions > Rescan Licenses).Audit your license regex for edge cases
Even if you think your regex is correct, small details can break matching in auto-scans:- Did you account for line breaks? Add the
(?s)prefix (DOTALL mode) to let.match newlines if your license spans multiple lines. - Are there unintended spaces or case sensitivity issues? Test your regex against the exact text pulled from the manual scan to ensure it matches perfectly.
- Did you escape special characters in your company name (like
.or&)? Artifactory uses Java regex syntax, so special characters need proper escaping.
- Did you account for line breaks? Add the
Check artifact indexing status
Artifactory relies on artifact indexes to scan archive contents. Navigate to your jar's details page, go to theIndextab, and confirm indexing completed successfully. If it failed, trigger a reindex (Actions > Reindex) and wait for it to finish before checking license recognition again.Ensure scan paths include the jar root directory
By default, Artifactory might only scan specific paths likeMETA-INF/. Go to Admin > Licenses > License Types, edit your custom license, and check theArchive Paths to Scanfield—addLICENSE.txt(or/LICENSE.txt) to explicitly tell Artifactory to look for the file at the jar's root.Dig into Artifactory logs for error clues
Check theartifactory.logfile (usually located in$ARTIFACTORY_HOME/logs) for entries related to your artifact or license scanning. Look for messages likeFailed to extract license fileorNo matches found for license regex—these will pinpoint exactly where the auto-scan is failing.Reconfirm Maven packaging places LICENSE.txt at the jar root
Even though manual scan finds it, double-check your jar structure withjar tf your-artifact.jarto ensureLICENSE.txtis at the root (not nested insrc/orresources/). If it's misplaced, adjust your Maven resources plugin configuration to copy it correctly:<build> <resources> <resource> <directory>${project.basedir}</directory> <includes> <include>LICENSE.txt</include> </includes> <targetPath>/</targetPath> </resource> </resources> </build>
内容的提问来源于stack exchange,提问作者François Guertin

