
com.carrotgarden.maven.scalor.eclipse.Props.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of scalor-maven-plugin_2.12 Show documentation
Show all versions of scalor-maven-plugin_2.12 Show documentation
Build integrator for Java, Scala, Scala.macro, Scala.js, Scala.native, Eclipse and Maven
The newest version!
package com.carrotgarden.maven.scalor.eclipse
import java.io.File
import java.io.FileOutputStream
import org.eclipse.jface.preference.IPreferenceStore
import org.eclipse.jface.preference.PreferenceStore
/**
* Properties support.
*/
trait Props {
import com.carrotgarden.maven.scalor.util.Error._
import com.carrotgarden.maven.scalor.util.Folder._
/**
* Optionally provide header comment in preference store.
*/
def persistComment(
storage : IPreferenceStore,
comment : String
) : Unit = TryHard {
val klaz = classOf[ PreferenceStore ]
val store = storage.asInstanceOf[ PreferenceStore ]
val field = klaz.getDeclaredField( "filename" )
field.setAccessible( true )
val filename = field.get( store ).asInstanceOf[ String ]
val file = new File( filename )
ensureParent( file )
val stream = new FileOutputStream( file )
store.save( stream, comment )
stream.close
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy