Skip to content

Commit

Permalink
Revert "Add template change watcher for livereload (#398)"
Browse files Browse the repository at this point in the history
This reverts commit 84954de.
  • Loading branch information
casid committed Nov 18, 2024
1 parent 1513abf commit 1ea5060
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 31 deletions.
4 changes: 0 additions & 4 deletions jte-spring-boot-starter-3/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,6 @@
<artifactId>spring-webflux</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
</dependency>
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,11 @@
import gg.jte.ContentType;
import gg.jte.TemplateEngine;
import gg.jte.resolve.DirectoryCodeResolver;
import java.io.File;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.devtools.filewatch.FileSystemWatcher;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.web.servlet.view.AbstractTemplateViewResolver;

import java.nio.file.FileSystems;
Expand All @@ -31,9 +24,6 @@ public JteAutoConfiguration(JteProperties jteProperties) {
this.jteProperties = jteProperties;
}


Logger logger = LoggerFactory.getLogger(JteAutoConfiguration.class);

@Bean
@ConditionalOnMissingBean(JteViewResolver.class)
public JteViewResolver jteViewResolver(TemplateEngine templateEngine) {
Expand All @@ -59,21 +49,4 @@ public TemplateEngine jteTemplateEngine() {
}
throw new JteConfigurationException("You need to either set gg.jte.usePrecompiledTemplates or gg.jte.developmentMode to true ");
}

@Bean
@ConditionalOnProperty(name = "gg.jte.developmentMode", havingValue = "true")
FileSystemWatcher viewComponentFileSystemWatcher(ApplicationContext applicationContext, JteProperties jteProperties) {
var fileSystemWatcher = new FileSystemWatcher();
File jteDir = new File(jteProperties.getTemplateLocation());
fileSystemWatcher.addSourceDirectory(jteDir);
logger.info("Watching for template changes at: {}", jteDir.getAbsoluteFile().getPath());
fileSystemWatcher.addListener(
changeSet -> {
logger.debug("Detected change to template: {}", changeSet);
applicationContext.publishEvent(new ContextRefreshedEvent(applicationContext));
}
);
fileSystemWatcher.start();
return fileSystemWatcher;
}
}

0 comments on commit 1ea5060

Please sign in to comment.