Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
openmole
openmole
Commits
4fdc17ed
Commit
4fdc17ed
authored
Apr 16, 2019
by
Romain Reuillon
Browse files
[Core] fix: remove the worflow statement at the end of the imported files
parent
9f348692
Changes
5
Hide whitespace changes
Inline
Side-by-side
libraries/build.sbt
View file @
4fdc17ed
...
...
@@ -114,6 +114,7 @@ lazy val scalaLang = OsgiProject(
"jline"
%
"jline"
%
"2.12.1"
,
"org.scala-stm"
%%
"scala-stm"
%
"0.8"
,
"com.typesafe"
%
"config"
%
"1.2.1"
,
"org.scalameta"
%%
"scalameta"
%
"4.1.0"
,
"org.scala-lang"
%
"scala-compiler"
%
scalaVersion
.
value
)
},
version
:=
scalaVersion
.
value
)
settings
(
settings
:
_
*
)
...
...
openmole/build.sbt
View file @
4fdc17ed
...
...
@@ -265,7 +265,9 @@ lazy val console = OsgiProject(coreDir, "org.openmole.core.console", global = tr
defaultActivator
)
dependsOn
(
openmoleOSGi
,
workspace
,
fileService
)
settings
(
coreSettings
:
_
*
)
lazy
val
project
=
OsgiProject
(
coreDir
,
"org.openmole.core.project"
,
imports
=
Seq
(
"*"
))
dependsOn
(
console
,
openmoleDSL
,
services
)
settings
(
OsgiKeys
.
importPackage
:=
Seq
(
"*"
))
settings
(
coreSettings
:
_
*
)
lazy
val
project
=
OsgiProject
(
coreDir
,
"org.openmole.core.project"
,
imports
=
Seq
(
"*"
))
dependsOn
(
console
,
openmoleDSL
,
services
)
settings
(
OsgiKeys
.
importPackage
:=
Seq
(
"*"
))
settings
(
coreSettings
:
_
*
)
settings
(
Libraries
.
addScalaLang
(
scalaVersionValue
)
)
lazy
val
buildinfo
=
OsgiProject
(
coreDir
,
"org.openmole.core.buildinfo"
,
imports
=
Seq
(
"*"
))
enablePlugins
(
BuildInfoPlugin
)
settings
(
//sourceGenerators in Compile += buildInfo.taskValue,
...
...
openmole/core/org.openmole.core.project/src/main/scala/org/openmole/core/project/Project.scala
View file @
4fdc17ed
...
...
@@ -17,7 +17,6 @@
*/
package
org.openmole.core.project
import
javax.script.CompiledScript
import
org.openmole.core.console._
import
org.openmole.core.pluginmanager._
import
org.openmole.core.project.Imports.
{
SourceFile
,
Tree
}
...
...
@@ -26,7 +25,6 @@ import monocle.function.all._
import
monocle.std.all._
import
org.openmole.core.exception.
{
InternalProcessingError
,
UserBadDataError
}
import
org.openmole.core.fileservice.FileService
import
org.openmole.core.outputmanager.OutputManager
import
org.openmole.core.services._
import
org.openmole.core.workflow.composition.DSL
import
org.openmole.core.workspace.NewFile
...
...
@@ -55,7 +53,7 @@ object Project {
def
makeVal
(
identifier
:
String
,
file
:
File
)
=
s
"""lazy val ${identifier} = ${uniqueName(file)}"""
def
makeScriptImports
(
sourceFile
:
SourceFile
)
=
{
def
makeScript
With
Imports
(
sourceFile
:
SourceFile
)
=
{
def
imports
=
makeImportTree
(
Tree
.
insertAll
(
sourceFile
.
importedFiles
))
val
name
=
uniqueName
(
sourceFile
.
file
)
...
...
@@ -69,12 +67,32 @@ object Project {
"""
}
def
makeScript
(
sourceFile
:
SourceFile
)
=
{
def
makeImportedScript
(
sourceFile
:
SourceFile
)
=
{
def
removeLastTerm
(
classContent
:
String
)
=
{
import
_root_.scala.meta._
val
source
=
classContent
.
parse
[
Source
].
get
val
cls
=
source
.
stats
.
last
.
asInstanceOf
[
Defn.Class
]
val
lastStat
=
cls
.
templ
.
stats
.
last
val
newCls
=
lastStat
match
{
case
_:
Term
⇒
cls.copy
(
templ
=
cls.templ.copy
(
stats
=
cls.templ.stats.dropRight
(
1
)))
case
x
⇒
println
(
x
.
getClass
)
cls
}
source
.
copy
(
stats
=
source
.
stats
.
dropRight
(
1
)
++
Seq
(
newCls
))
}
def
imports
=
makeImportTree
(
Tree
.
insertAll
(
sourceFile
.
importedFiles
))
val
name
=
uniqueName
(
sourceFile
.
file
)
s
"""class ${name}Class {
val
classContent
=
s
"""class ${name}Class {
|lazy val _imports = new {
|$imports
|}
...
...
@@ -82,9 +100,12 @@ object Project {
|import _imports._
|
|private lazy val ${ConsoleVariables.workDirectory} = File(new java.net.URI("${sourceFile.file.getParentFileSafe.toURI}").getPath)
|
|${sourceFile.file.content}
|}
|
"""
.
stripMargin
s
"""${removeLastTerm(classContent)}
|lazy val ${name} = new ${name}Class
"""
.
stripMargin
}
...
...
@@ -92,7 +113,7 @@ object Project {
val
allImports
=
Imports
.
importedFiles
(
script
)
// The first script is the script being compiled itself, no need to include its vars and defs, it would be redundant
def
importHeader
=
{
allImports
.
take
(
1
).
map
(
makeScriptImports
)
++
allImports
.
drop
(
1
).
map
(
makeScript
)
}.
mkString
(
"\n"
)
def
importHeader
=
{
allImports
.
take
(
1
).
map
(
makeScript
With
Imports
)
++
allImports
.
drop
(
1
).
map
(
make
Imported
Script
)
}.
mkString
(
"\n"
)
s
"""
|$importHeader
...
...
openmole/core/org.openmole.core.serializer/src/main/scala/org/openmole/core/serializer/PluginAndFilesListing.scala
View file @
4fdc17ed
...
...
@@ -19,24 +19,16 @@ package org.openmole.core.serializer
import
java.io.File
import
com.thoughtworks.xstream.converters.
{
Converter
,
ConverterLookup
}
import
com.thoughtworks.xstream.converters.reflection.ReflectionConverter
import
com.thoughtworks.xstream.core.
{
ClassLoaderReference
,
DefaultConverterLookup
,
JVM
}
import
com.thoughtworks.xstream.core.util.CompositeClassLoader
import
com.thoughtworks.xstream.io.xml.XppDriver
import
com.thoughtworks.xstream.
{
XStream
,
mapper
}
import
com.thoughtworks.xstream.mapper.
{
DefaultMapper
,
Mapper
,
MapperWrapper
}
import
org.openmole.core.pluginmanager.PluginManager
import
org.openmole.core.serializer.converter.Serialiser
import
org.openmole.core.serializer.file.FileConverterNotifier
import
org.openmole.core.serializer.plugin.
{
PluginClassConverter
,
PluginConverter
,
Plugins
}
import
org.openmole.core.serializer.plugin.
{
PluginClassConverter
,
PluginConverter
}
import
org.openmole.core.serializer.structure.PluginClassAndFiles
import
org.openmole.tool.file._
import
org.openmole.tool.stream.NullOutputStream
import
org.openmole.core.console._
import
scala.collection.immutable.
{
HashSet
,
TreeSet
}
import
scala.reflect.internal.util.ScalaClassLoader.URLClassLoader
object
PluginAndFilesListing
{
def
looksLikeREPLClassName
(
p
:
String
)
=
p
.
startsWith
(
"$line"
)
...
...
@@ -57,6 +49,7 @@ trait PluginAndFilesListing { this: Serialiser ⇒
xStream
.
registerConverter
(
new
PluginClassConverter
(
this
))
def
classUsed
(
c
:
Class
[
_
])
=
{
if
(!
seenClasses
.
contains
(
c
))
{
if
(
PluginManager
.
isClassProvidedByAPlugin
(
c
))
PluginManager
.
pluginsForClass
(
c
).
foreach
(
pluginUsed
)
...
...
openmole/project/Libraries.scala
View file @
4fdc17ed
...
...
@@ -49,7 +49,11 @@ object Libraries {
/** ------- Bundles -------------- */
def
addScalaLang
(
scalaVersion
:
String
)
=
libraryDependencies
+=
"org.openmole.library"
%%
"org-scala-lang-scala-library"
%
scalaVersion
def
addScalaLang
(
scalaVersion
:
String
)
=
libraryDependencies
++=
Seq
(
"org.openmole.library"
%%
"org-scala-lang-scala-library"
%
scalaVersion
,
"org.scalameta"
%%
"scalameta"
%
"4.1.0"
)
lazy
val
scalatra
=
"org.openmole.library"
%%
"org-scalatra"
%
"2.6.3"
lazy
val
logback
=
"org.openmole.library"
%%
"ch-qos-logback"
%
"1.0.9"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment