1

I'm using spotless to format code in my project. I've decided to use WTP plugin to format html, css and js in this projet.

There should be a config to select the way html is formated. eg. with space instead of tab.

https://github.com/diffplug/spotless/tree/main/plugin-gradle#eclipse-web-tools-platform

The file path given is .metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.wst.html.core.prefs.

But I have no clue where this file is. I tryed to install elicpse and find the given file, with no luck.

benzen
  • 6,204
  • 4
  • 25
  • 37
  • That's a path relative to where you locate your workspace--it'll be *in* the workspace once you create the workspace (although possibly require you go in and change a preference before the file itself will be created). – nitind Feb 08 '21 at 14:55
  • Do you know a guide on the property that could be used there ? – benzen Feb 08 '21 at 15:10

2 Answers2

2

As mentiontioned by @nitind the file is in the workspace. The way i found it was to run the following commend.

find ~/ -name 'org.eclipse.wst.html.core.prefs'

benzen
  • 6,204
  • 4
  • 25
  • 37
1

Just FYI here's spotless-maven-plugin configuration (as specified in pom.xml) and the Eclipse preferences file I ended up using - I am using Netbeans as my development platform. I still haven't figured out if everything works as it should though. Because it seems that e.g. spotless' own <indent> configuration seems to need to be specified apart from eclipseWtp, because the latter doesn't do tab-to-spaces substitution exactly the way I expect it to do it.

...
<plugin>
    <groupId>com.diffplug.spotless</groupId>
    <artifactId>spotless-maven-plugin</artifactId>
    <version>2.29.0</version>
    <executions>
        <execution>
            <goals>
                <goal>check</goal>
            </goals>
            <phase>validate</phase>
        </execution>
    </executions>
    <configuration>
        <formats>
           <format>
              <includes>
                 <include>**/*.html</include>
              </includes>
              <eclipseWtp>
                 <type>HTML</type>
                 <files>
                    <file>${project.basedir}/src/main/resources/org.eclipse.wst.html.core.prefs</file>
                 </files>
              </eclipseWtp>
              <trimTrailingWhitespace/>
              <endWithNewline/>
              <indent>
                 <spaces>true</spaces>
                 <spacesPerTab>4</spacesPerTab>
              </indent>                        
           </format>
        </formats>                   
        <java>
           <toggleOffOn/>
           <importOrder/>
           <removeUnusedImports/>
            <indent>
                <spaces>true</spaces>
                <spacesPerTab>4</spacesPerTab>
            </indent>
           <trimTrailingWhitespace />
           <formatAnnotations/>                        
           <palantirJavaFormat></palantirJavaFormat>
        </java>                    
    </configuration>   
</plugin>
...

And here's contents of org.eclipse.wst.html.core.prefs file I have placed into aforementioned ${project.basedir}/src/main/resources folder (I did a rough search on the internet to find core and html specific content):

lineWidth=72
clearAllBlankLines=false
indentationChar=space
indentationSize=4
splitMultiAttrs=false
alignEndBracket=false
cleanupTagNameCase=0
cleanupAttrNameCase=0
insertRequiredAttrs=false
insertMissingTags=false
quoteAttrValues=true
formatSource=true
convertEOLCodes=false
inputCodeset=
outputCodeset=UTF-8
endOfLineCode=
tagNameCase=1
attrNameCase=1
defaultExtension=html
inlineElements=a,abbr,acronym,b,basefont,big,br,cite,em,font,i,img,input,label,li,q,s,select,small,span,strike,strong,sub,sup,td,th,title,u

attrDuplicate=2
attrInvalidName=2
attrInvalidValue=2
attrNameMismatch=2
attrNamesToIgnore=
attrUndefName=2
attrUndefValue=2
attrValueEqualsMissing=2
attrValueMismatch=1
attrValueUnclosed=2
cdataInvalidContent=2
cdataUnclosed=1
commentInvalidContent=2
commentUnclosed=1
docDoctypeUnclosed=1
docDuplicateTag=1
docInvalidChar=2
docInvalidContent=2
eclipse.preferences.version=1
elemCoexistence=2
elemDuplicate=2
elemEndInvalidCase=1
elemInvalidContent=2
elemInvalidDirective=1
elemInvalidEmptyTag=2
elemInvalidName=1
elemInvalidText=2
elemMissingEnd=2
elemMissingStart=2
elemStartInvalidCase=2
elemUnclosedEndTag=1
elemUnclosedStartTag=1
elemUnknownName=-1
elemUnnecessaryEnd=2
ignoreAttrNames=false
ignoreElementNames=false
piInvalidContent=2
piUnclosed=1
piUndefined=2
refInvalidContent=2
resourceNotFound=2
hello_earth
  • 1,442
  • 1
  • 25
  • 39