- 
        Couldn't load subscription status. 
- Fork 489
Add documentation showing how to share configuration #2643
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Open
      
      
            rnc
  wants to merge
  1
  commit into
  diffplug:main
  
    
      
        
          
  
    
      Choose a base branch
      
     
    
      
        
      
      
        
          
          
        
        
          
            
              
              
              
  
           
        
        
          
            
              
              
           
        
       
     
  
        
          
            
          
            
          
        
       
    
      
from
rnc:I2428
  
      
      
   
  
    
  
  
  
 
  
      
    base: main
Could not load branches
            
              
  
    Branch not found: {{ refName }}
  
            
                
      Loading
              
            Could not load tags
            
            
              Nothing to show
            
              
  
            
                
      Loading
              
            Are you sure you want to change the base?
            Some commits from the old base branch may be removed from the timeline,
            and old review comments may become outdated.
          
          
  
     Open
                    Changes from all commits
      Commits
    
    
  File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|  | @@ -93,6 +93,7 @@ Spotless supports all of Gradle's built-in performance features (incremental bui | |||||
| - [Dependency resolution modes](#dependency-resolution-modes) | ||||||
| - [How do I preview what `spotlessApply` will do?](#how-do-i-preview-what-spotlessapply-will-do) | ||||||
| - [Can I apply Spotless to specific files?](#can-i-apply-spotless-to-specific-files) | ||||||
| - [Sharing Spotless Configuration](#sharing-configuration) | ||||||
| - [Example configurations (from real-world projects)](#example-configurations-from-real-world-projects) | ||||||
|  | ||||||
| ***Contributions are welcome, see [the contributing guide](../CONTRIBUTING.md) for development info.*** | ||||||
|  | @@ -1908,6 +1909,26 @@ cmd> gradle spotlessApply -PspotlessFiles=my/file/pattern.java,more/generic/.*-p | |||||
|  | ||||||
| The patterns are matched using `String#matches(String)` against the absolute file path. | ||||||
|  | ||||||
| ## Sharing Configuration | ||||||
|  | ||||||
| Rather than copying the formatter files across many projects, it is possible to define a common configuration that is deployed as a standard artifact so that it can be then be reused by each project; for example: | ||||||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 
        Suggested change
       
 In german it could be like this to give dedication and separation. But its en so idk. Ned should fine tune this. Its not so important. Rest is perfecly fine. | ||||||
|  | ||||||
| ```kotlin | ||||||
| val spotlessConfig by configurations.creating | ||||||
| dependencies { | ||||||
| spotlessConfig("org.mycompany:code-configuration:1.0.0") | ||||||
| } | ||||||
| spotless { | ||||||
| java { | ||||||
| removeUnusedImports() | ||||||
| importOrder(resources.text.fromArchiveEntry(spotlessConfig, "java-import-order.txt").asString()) | ||||||
| eclipse().configXml(resources.text.fromArchiveEntry(spotlessConfig, "java-formatter.xml").asString()) | ||||||
| } | ||||||
| } | ||||||
| ``` | ||||||
|  | ||||||
| In this example, the files `java-import-order.txt` and `java-formatter.xml` should be at the root of the deployed `org.mycompany:code-configuration:1.0.0` jar. | ||||||
|  | ||||||
| ## Example configurations (from real-world projects) | ||||||
|  | ||||||
| * [A few thousand github projects](https://github.com/search?l=gradle&q=spotless&type=Code) | ||||||
|  | ||||||
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the previous point, the verbs appear in their base form — preview, apply, share — rather than in their continuous forms (previewing, applying, sharing).
We could continue using this style for consistency, ensuring a cohesive look and feel.