forked from Frege/frege-gradle-plugin
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from tricktron/f-repl-frege-v2
Frege Repl Refactoring
- Loading branch information
Showing
7 changed files
with
429 additions
and
359 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
group = ch.fhnw.thga | ||
version = 1.4.1-alpha | ||
version = 1.5.0-alpha |
685 changes: 377 additions & 308 deletions
685
src/functionalTest/java/ch/fhnw/thga/gradleplugins/FregePluginFunctionalTest.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 7 additions & 43 deletions
50
src/main/java/ch/fhnw/thga/gradleplugins/ReplFregeTask.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,19 @@ | ||
package ch.fhnw.thga.gradleplugins; | ||
|
||
import javax.inject.Inject; | ||
|
||
import org.gradle.api.DefaultTask; | ||
import org.gradle.api.file.DirectoryProperty; | ||
import org.gradle.api.file.FileCollection; | ||
import org.gradle.api.file.RegularFileProperty; | ||
import org.gradle.api.logging.Logger; | ||
import org.gradle.api.logging.Logging; | ||
import org.gradle.api.model.ObjectFactory; | ||
import org.gradle.api.provider.Property; | ||
import org.gradle.api.provider.Provider; | ||
import org.gradle.api.tasks.Input; | ||
import org.gradle.api.tasks.InputDirectory; | ||
import org.gradle.api.tasks.InputFile; | ||
import org.gradle.api.tasks.Internal; | ||
import org.gradle.api.tasks.JavaExec; | ||
import org.gradle.api.file.ConfigurableFileCollection; | ||
import org.gradle.api.tasks.InputFiles; | ||
import org.gradle.api.tasks.TaskAction; | ||
|
||
public abstract class ReplFregeTask extends DefaultTask { | ||
public static final Logger LOGGER = Logging.getLogger(SetupFregeTask.class); | ||
public static final String REPL_MAIN_CLASS = "frege.repl.FregeRepl"; | ||
|
||
private final JavaExec javaExec; | ||
|
||
@InputFile | ||
public abstract RegularFileProperty getFregeCompilerJar(); | ||
|
||
@InputDirectory | ||
public abstract DirectoryProperty getFregeOutputDir(); | ||
|
||
@Input | ||
public abstract Property<String> getFregeDependencies(); | ||
|
||
@Internal | ||
public final Provider<FileCollection> getClasspath() { | ||
return getFregeDependencies().map(depsClasspath -> { | ||
return depsClasspath.isEmpty() ? getProject().files(getFregeCompilerJar(), getFregeOutputDir()) | ||
: getProject().files(getFregeCompilerJar(), getFregeOutputDir(), depsClasspath); | ||
}); | ||
} | ||
|
||
@Inject | ||
public ReplFregeTask(ObjectFactory objectFactory) { | ||
javaExec = objectFactory.newInstance(JavaExec.class); | ||
} | ||
@InputFiles | ||
public abstract ConfigurableFileCollection getFregeClasspath(); | ||
|
||
@TaskAction | ||
public void startFregeRepl() { | ||
javaExec.setStandardInput(System.in); | ||
javaExec.getMainClass().set(REPL_MAIN_CLASS); | ||
javaExec.setClasspath(getClasspath().get()).exec(); | ||
public void printStartFregeReplCommand() { | ||
System.out.println("Execute the following command to start the Frege Repl:"); | ||
System.out.println(String.format("java -cp %s %s", getFregeClasspath().getAsPath(), REPL_MAIN_CLASS)); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/main/java/ch/fhnw/thga/gradleplugins/internal/DependencyFregeTask.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package ch.fhnw.thga.gradleplugins.internal; | ||
|
||
import org.gradle.api.DefaultTask; | ||
import org.gradle.api.file.ConfigurableFileCollection; | ||
import org.gradle.api.tasks.InputFiles; | ||
import org.gradle.api.tasks.TaskAction; | ||
|
||
public abstract class DependencyFregeTask extends DefaultTask { | ||
@InputFiles | ||
public abstract ConfigurableFileCollection getClasspath(); | ||
|
||
@TaskAction | ||
public void fregeDependencies() { | ||
System.out.println(getClasspath().getAsPath()); | ||
} | ||
} |