Minimum json during assembly jar in gradle



  • The {project}/src/main/resources are based on different formats.
    I need to minimise all of it during the course of my ride.
    I want to do the same thing with.
    How do you use gradle?



  • https://docs.gradle.org/current/dsl/org.gradle.api.tasks.Copy.html May use filters:

    task minimize(type: Copy) {
        from('src/main/resources') {
            include '**/*.json'
            include '**/*.xml'
            include '**/*.css'
            filter(org.apache.tools.ant.filters.StripLineBreaks)
            filter(StripDoubleSpaces)
        }
        into 'target'
    }
    

    Standard ant filter StripLineBreaks can be used to remove tubes. In order to remove the double gaps, it may be necessary to write a filter because the filter to replace the regular expressions in ant realized as "plagin' to TokenFilter, which should be added to the filter chain by the TokenFilter.add(), and filter(s) is not accepted at the inlet but the type, that is, TokenFilter will not be configurated.

    public class StripLineBreaks extends org.apache.tools.ant.filters.TokenFilter {
        public StripLineBreaks() {
            ReplaceRegex regexFilter = new ReplaceRegex();
            regexFilter.setPattern( "\\s+" );
            regexFilter.setReplace( " " );
            add( regexFilter );
        }
    }
    



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2