Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SableCC Gradle plugin
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
general
stups
SableCC Gradle plugin
Commits
ec95eaf6
Commit
ec95eaf6
authored
5 months ago
by
dgelessus
Browse files
Options
Downloads
Patches
Plain Diff
Get and convert paths only once
parent
4c7736b6
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/de/hhu/stups/sablecc/gradle/SableCCTask.java
+11
-7
11 additions, 7 deletions
src/main/java/de/hhu/stups/sablecc/gradle/SableCCTask.java
with
11 additions
and
7 deletions
src/main/java/de/hhu/stups/sablecc/gradle/SableCCTask.java
+
11
−
7
View file @
ec95eaf6
...
...
@@ -3,6 +3,7 @@ package de.hhu.stups.sablecc.gradle;
import
java.io.File
;
import
java.io.IOException
;
import
java.nio.file.Files
;
import
java.nio.file.Path
;
import
java.util.ArrayList
;
import
java.util.List
;
...
...
@@ -103,10 +104,13 @@ public abstract class SableCCTask extends SourceTask {
@TaskAction
void
execute
()
throws
IOException
{
Path
destinationJavaPath
=
this
.
getDestinationJavaDir
().
getAsFile
().
toPath
();
Path
destinationResourcesPath
=
this
.
getDestinationResourcesDir
().
getAsFile
().
toPath
();
// Delete any previously generated source files, so that no longer existing token and node classes aren't kept around.
this
.
getFs
().
delete
(
spec
->
spec
.
delete
(
this
.
getD
estinationJava
Dir
(),
this
.
getD
estinationResources
Dir
()
));
Files
.
createDirectories
(
this
.
getD
estinationJava
Dir
().
getAsFile
().
to
Path
()
);
Files
.
createDirectories
(
this
.
getD
estinationResources
Dir
().
getAsFile
().
to
Path
()
);
this
.
getFs
().
delete
(
spec
->
spec
.
delete
(
d
estinationJava
Path
,
d
estinationResources
Path
));
Files
.
createDirectories
(
d
estinationJavaPath
);
Files
.
createDirectories
(
d
estinationResourcesPath
);
// Call SableCC to generate the source files.
this
.
getExecOperations
().
javaexec
(
spec
->
{
...
...
@@ -115,7 +119,7 @@ public abstract class SableCCTask extends SourceTask {
spec
.
getMainClass
().
set
(
"org.sablecc.sablecc.SableCC"
);
final
List
<
String
>
args
=
new
ArrayList
<>();
args
.
add
(
"-d"
);
args
.
add
(
destinationJava
Dir
.
get
().
getAsFile
().
getPath
());
args
.
add
(
destinationJava
Path
.
toString
());
for
(
final
File
file
:
this
.
getSource
().
getFiles
())
{
args
.
add
(
file
.
getPath
());
}
...
...
@@ -124,13 +128,13 @@ public abstract class SableCCTask extends SourceTask {
// Move generated dat files from Java source directory to resources directory.
this
.
getFs
().
copy
(
spec
->
{
spec
.
from
(
this
.
getD
estinationJava
Dir
()
);
spec
.
into
(
this
.
getD
estinationResources
Dir
()
);
spec
.
from
(
d
estinationJava
Path
);
spec
.
into
(
d
estinationResources
Path
);
spec
.
include
(
"**/*.dat"
);
});
this
.
getFs
().
delete
(
spec
->
{
ConfigurableFileTree
fileTree
=
this
.
objectFactory
.
fileTree
();
fileTree
.
from
(
this
.
getD
estinationJava
Dir
()
);
fileTree
.
from
(
d
estinationJava
Path
);
fileTree
.
include
(
"**/*.dat"
);
spec
.
delete
(
fileTree
);
});
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment