Minimize and centralize assumptions about build output
Closes gh-15471
This commit is contained in:
@@ -19,20 +19,32 @@ package sample.parent.producer;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import sample.parent.ServiceProperties;
|
||||
|
||||
import org.springframework.boot.ApplicationArguments;
|
||||
import org.springframework.boot.ApplicationRunner;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
public class ProducerApplication implements CommandLineRunner {
|
||||
@EnableConfigurationProperties(ServiceProperties.class)
|
||||
public class ProducerApplication implements ApplicationRunner {
|
||||
|
||||
private final ServiceProperties serviceProperties;
|
||||
|
||||
public ProducerApplication(ServiceProperties serviceProperties) {
|
||||
this.serviceProperties = serviceProperties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(String... args) throws Exception {
|
||||
new File("target/input").mkdirs();
|
||||
if (args.length > 0) {
|
||||
public void run(ApplicationArguments args) throws Exception {
|
||||
this.serviceProperties.getInputDir().mkdirs();
|
||||
if (args.getNonOptionArgs().size() > 0) {
|
||||
FileOutputStream stream = new FileOutputStream(
|
||||
"target/input/data" + System.currentTimeMillis() + ".txt");
|
||||
for (String arg : args) {
|
||||
new File(this.serviceProperties.getInputDir(),
|
||||
"data" + System.currentTimeMillis() + ".txt"));
|
||||
for (String arg : args.getNonOptionArgs()) {
|
||||
stream.write(arg.getBytes());
|
||||
}
|
||||
stream.flush();
|
||||
|
||||
Reference in New Issue
Block a user