本文整理汇总了Java中org.lesscss.LessSource类的典型用法代码示例。如果您正苦于以下问题:Java LessSource类的具体用法?Java LessSource怎么用?Java LessSource使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LessSource类属于org.lesscss包,在下文中一共展示了LessSource类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: instantiate
import org.lesscss.LessSource; //导入依赖的package包/类
/**
* instantiates the actual less compilement
*
* @throws Exception
*/
public void instantiate() throws Exception
{
instantiateFiles();
final LessSource mainLessSource = compile();
if (Configuration.isDevelopmentMode() == true) {
// only add this fancy resource watcher in dev mode
final IModificationWatcher resourceWatcher = application.getResourceSettings().getResourceWatcher(true);
// add watchers
addWatcher(resourceWatcher, mainLessSource);
for (final LessSource importedSource : mainLessSource.getImports().values()) {
addWatcher(resourceWatcher, importedSource);
}
}
// mount compiled css file
reference = new LessResourceReference(relativeCssPath, cssTargetFile);
application.mountResource(encodePathWithCachingStrategy(relativeCssPath), reference);
}
示例2: addWatcher
import org.lesscss.LessSource; //导入依赖的package包/类
/**
* adds a resource watcher entry to the given less source
*
* @param resourceWatcher
* @param importedSource
*/
private void addWatcher(final IModificationWatcher resourceWatcher, final LessSource importedSource)
{
log.info("adding watcher to less file " + importedSource.getAbsolutePath());
resourceWatcher.add(new org.apache.wicket.util.file.File(new File(importedSource.getAbsolutePath())), new IChangeListener() {
@Override
public void onChange()
{
try {
compile();
} catch (final Exception e) {
log.error("unable to compile less source during watcher for file " + importedSource.getAbsolutePath(), e);
}
}
});
}
示例3: compile
import org.lesscss.LessSource; //导入依赖的package包/类
/**
* compiles the saved .less to the wanted .css file
*
* @return
* @throws Exception
*/
private LessSource compile() throws Exception
{
// compile file
final LessCompiler lessCompiler = new LessCompiler();
// create new source
final LessSource mainLessSource = new LessSource(lessTargetFile);
log.info("compiling " + lessTargetFile.getAbsolutePath() + " to " + cssTargetFile.getAbsolutePath());
lessCompiler.compile(mainLessSource, cssTargetFile, false);
return mainLessSource;
}