#12 -- Add build tool components
parent
5153270239
commit
8d3e7f4e2e
@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Anton Romanov - All Rights Reserved
|
||||
* You may use, distribute and modify this code, please write to: romanov73@gmail.com.
|
||||
*/
|
||||
|
||||
package ru.ulstu.extractor.heuristic.component;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class BuildTool {
|
||||
private final String name;
|
||||
|
||||
public BuildTool(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public abstract boolean canAppliedToProject(List<File> rootProjectFiles);
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public abstract String getSourceDirectoryPath();
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Anton Romanov - All Rights Reserved
|
||||
* You may use, distribute and modify this code, please write to: romanov73@gmail.com.
|
||||
*/
|
||||
|
||||
package ru.ulstu.extractor.heuristic.component;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
public class GradleBuildTool extends BuildTool {
|
||||
|
||||
public GradleBuildTool() {
|
||||
super("Gradle");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAppliedToProject(List<File> rootProjectFiles) {
|
||||
return rootProjectFiles.stream()
|
||||
.anyMatch(file -> file.getName().equals("build.gradle") || file.getName().equals("settings.gradle"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSourceDirectoryPath() {
|
||||
return "src";
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Anton Romanov - All Rights Reserved
|
||||
* You may use, distribute and modify this code, please write to: romanov73@gmail.com.
|
||||
*/
|
||||
|
||||
package ru.ulstu.extractor.heuristic.component;
|
||||
|
||||
public class JavaProgrammingLanguage extends ProgrammingLanguage {
|
||||
public JavaProgrammingLanguage() {
|
||||
super("java");
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Anton Romanov - All Rights Reserved
|
||||
* You may use, distribute and modify this code, please write to: romanov73@gmail.com.
|
||||
*/
|
||||
|
||||
package ru.ulstu.extractor.heuristic.component;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
public class MavenBuildTool extends BuildTool {
|
||||
|
||||
public MavenBuildTool() {
|
||||
super("Maven");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAppliedToProject(List<File> rootProjectFiles) {
|
||||
return rootProjectFiles.stream()
|
||||
.anyMatch(file -> file.getName().equals("pom.xml"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSourceDirectoryPath() {
|
||||
return "src";
|
||||
}
|
||||
}
|
@ -1,4 +1,9 @@
|
||||
package ru.ulstu.extractor.heuristic.model;
|
||||
/*
|
||||
* Copyright (C) 2021 Anton Romanov - All Rights Reserved
|
||||
* You may use, distribute and modify this code, please write to: romanov73@gmail.com.
|
||||
*/
|
||||
|
||||
package ru.ulstu.extractor.heuristic.component;
|
||||
|
||||
public abstract class ProgrammingLanguage {
|
||||
private final String name;
|
@ -1,16 +0,0 @@
|
||||
package ru.ulstu.extractor.heuristic.model;
|
||||
|
||||
public abstract class BuildTool {
|
||||
private final String name;
|
||||
|
||||
public BuildTool(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
protected abstract boolean canAppliedToProject();
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
package ru.ulstu.extractor.heuristic.model;
|
||||
|
||||
public class GradleBuildTool extends BuildTool {
|
||||
|
||||
public GradleBuildTool() {
|
||||
super("Gradle");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canAppliedToProject() {
|
||||
return false;
|
||||
}
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
package ru.ulstu.extractor.heuristic.model;
|
||||
|
||||
public class JavaProgrammingLanguage extends ProgrammingLanguage {
|
||||
public JavaProgrammingLanguage() {
|
||||
super("java");
|
||||
}
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Anton Romanov - All Rights Reserved
|
||||
* You may use, distribute and modify this code, please write to: romanov73@gmail.com.
|
||||
*/
|
||||
|
||||
package ru.ulstu.extractor.heuristic.model;
|
||||
|
||||
public class MavenBuildTool extends BuildTool {
|
||||
|
||||
public MavenBuildTool() {
|
||||
super("Gradle");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canAppliedToProject() {
|
||||
return false;
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Anton Romanov - All Rights Reserved
|
||||
* You may use, distribute and modify this code, please write to: romanov73@gmail.com.
|
||||
*/
|
||||
|
||||
package ru.ulstu.extractor.heuristic.service;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import ru.ulstu.extractor.heuristic.component.BuildTool;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Service
|
||||
public class BuildToolService {
|
||||
private final List<BuildTool> buildTools;
|
||||
|
||||
public BuildToolService(List<BuildTool> buildTools) {
|
||||
this.buildTools = buildTools;
|
||||
}
|
||||
|
||||
public Optional<BuildTool> getProjectBuildTool(List<File> rootProjectFiles) {
|
||||
return buildTools.stream().filter(buildTool -> buildTool.canAppliedToProject(rootProjectFiles)).findAny();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue