I get a null pointer exception when setting enabled to false (as described in the doc):
<plugin>
<groupId>com.tunyk.mvn.plugins.htmlcompressor</groupId>
<artifactId>htmlcompressor-maven-plugin</artifactId>
<version>1.2</version>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>html</goal>
</goals>
</execution>
</executions>
<configuration>
<goalPrefix>htmlcompressor</goalPrefix>
<srcFolder>${basedir}/src/main/webapp/html</srcFolder>
<targetFolder>${basedir}/src/main/webapp/result/html</targetFolder>
<removeIntertagSpaces>true</removeIntertagSpaces>
<enabled>false</enabled>
</configuration>
</plugin>
Anyone knows why? Anyone has a solution?
P.S.: Here is maven -X:
[htmlcompressor:html]
com.tunyk.mvn.plugins.htmlcompressor:htmlcompressor-maven-plugin:jar:1.2:
com.googlecode.htmlcompressor:htmlcompressor:jar:1.4:compile
com.google.javascript:closure-compiler:jar:r1043:compile
args4j:args4j:jar:2.0.12:compile
com.google.guava:guava:jar:r08:compile
com.google.protobuf:protobuf-java:jar:2.3.0:compile
org.apache.ant:ant:jar:1.8.1:compile
org.apache.ant:ant-launcher:jar:1.8.1:compile
com.google.code.findbugs:jsr305:jar:1.3.9:compile
junit:junit:jar:4.8.2:compile
com.yahoo.platform.yui:yuicompressor:jar:2.4.6:compile
rhino:js:jar:1.6R7:compile
javax.servlet.jsp:jsp-api:jar:2.1:compile
org.apache.velocity:velocity-tools:jar:2.0:compile
commons-beanutils:commons-beanutils:jar:1.7.0:compile
commons-digester:commons-digester:jar:1.8:compile
commons-chain:commons-chain:jar:1.1:compile
commons-collections:commons-collections:jar:3.2:compile
commons-logging:commons-logging:jar:1.1:compile
javax.servlet:servlet-api:jar:2.3:compile
commons-validator:commons-validator:jar:1.3.1:compile
dom4j:dom4j:jar:1.1:compile
oro:oro:jar:2.0.8:compile
sslext:sslext:jar:1.2-0:compile
org.apache.struts:struts-core:jar:1.3.8:compile
antlr:antlr:jar:2.7.2:compile
org.apache.struts:struts-taglib:jar:1.3.8:compile
org.apache.struts:struts-tiles:jar:1.3.8:compile
org.apache.velocity:velocity:jar:1.6.2:compile
commons-lang:commons-lang:jar:2.4:compile
org.apache.commons:commons-io:jar:1.3.2:compile
org.json:json:jar:20090211:compile
org.apache.maven:maven-plugin-api:jar:3.0.3:compile
org.apache.maven:maven-model:jar:3.0.3:compile
org.codehaus.plexus:plexus-utils:jar:2.0.6:compile
org.apache.maven:maven-artifact:jar:3.0.3:compile
org.sonatype.sisu:sisu-inject-plexus:jar:2.1.1:compile
org.codehaus.plexus:plexus-component-annotations:jar:1.5.5:compile
org.codehaus.plexus:plexus-classworlds:jar:2.4:compile
org.sonatype.sisu:sisu-inject-bean:jar:2.1.1:compile
org.sonatype.sisu:sisu-guice:jar:no_aop:2.9.4:compile
org.slf4j:slf4j-api:jar:1.5.10:compile
org.slf4j:slf4j-log4j12:jar:1.5.10:compile
log4j:log4j:jar:1.2.14:compile
Created new class realm plugin>com.tunyk.mvn.plugins.htmlcompressor:htmlcompressor-maven-plugin:1.2
Importing foreign packages into class realm plugin>com.tunyk.mvn.plugins.htmlcompressor:htmlcompressor-maven-plugin:1.2
Imported: < maven.api
Populating class realm plugin>com.tunyk.mvn.plugins.htmlcompressor:htmlcompressor-maven-plugin:1.2
Included: com.tunyk.mvn.plugins.htmlcompressor:htmlcompressor-maven-plugin:jar:1.2
Included: com.googlecode.htmlcompressor:htmlcompressor:jar:1.4
Included: com.google.javascript:closure-compiler:jar:r1043
Included: args4j:args4j:jar:2.0.12
Included: com.google.guava:guava:jar:r08
Included: com.google.protobuf:protobuf-java:jar:2.3.0
Included: org.apache.ant:ant:jar:1.8.1
Included: org.apache.ant:ant-launcher:jar:1.8.1
Included: com.google.code.findbugs:jsr305:jar:1.3.9
Included: junit:junit:jar:4.8.2
Included: com.yahoo.platform.yui:yuicompressor:jar:2.4.6
Included: rhino:js:jar:1.6R7
Included: javax.servlet.jsp:jsp-api:jar:2.1
Included: org.apache.velocity:velocity-tools:jar:2.0
Included: commons-beanutils:commons-beanutils:jar:1.7.0
Included: commons-digester:commons-digester:jar:1.8
Included: commons-chain:commons-chain:jar:1.1
Included: commons-collections:commons-collections:jar:3.2
Included: commons-logging:commons-logging:jar:1.1
Included: javax.servlet:servlet-api:jar:2.3
Included: commons-validator:commons-validator:jar:1.3.1
Included: dom4j:dom4j:jar:1.1
Included: oro:oro:jar:2.0.8
Included: sslext:sslext:jar:1.2-0
Included: org.apache.struts:struts-core:jar:1.3.8
Included: antlr:antlr:jar:2.7.2
Included: org.apache.struts:struts-taglib:jar:1.3.8
Included: org.apache.struts:struts-tiles:jar:1.3.8
Included: org.apache.velocity:velocity:jar:1.6.2
Included: commons-lang:commons-lang:jar:2.4
Included: org.apache.commons:commons-io:jar:1.3.2
Included: org.json:json:jar:20090211
Included: org.codehaus.plexus:plexus-utils:jar:2.0.6
Included: org.codehaus.plexus:plexus-component-annotations:jar:1.5.5
Included: org.sonatype.sisu:sisu-inject-bean:jar:2.1.1
Included: org.sonatype.sisu:sisu-guice:jar:no_aop:2.9.4
Included: org.slf4j:slf4j-api:jar:1.5.10
Included: org.slf4j:slf4j-log4j12:jar:1.5.10
Included: log4j:log4j:jar:1.2.14
Excluded: org.apache.maven:maven-plugin-api:jar:3.0.3
Excluded: org.apache.maven:maven-model:jar:3.0.3
Excluded: org.apache.maven:maven-artifact:jar:3.0.3
Excluded: org.sonatype.sisu:sisu-inject-plexus:jar:2.1.1
Excluded: org.codehaus.plexus:plexus-classworlds:jar:2.4
Configuring mojo com.tunyk.mvn.plugins.htmlcompressor:htmlcompressor-maven-plugin:1.2:html from plugin realm ClassRealm[plugin>com.tunyk.mvn.plugins.htmlcompressor:htmlcompressor-maven-plugin:1.2, parent: sun.misc.Launcher$AppClassLoader#11b86e7]
Configuring mojo 'com.tunyk.mvn.plugins.htmlcompressor:htmlcompressor-maven-plugin:1.2:html' with basic configurator -->
(s) closureCustomExternsOnly = false
(s) closureExterns = []
(s) closureOptLevel = simple
(s) compressCss = false
(s) compressJavaScript = false
(s) enabled = false
(s) encoding = utf-8
(s) fileExt = []
(s) generateStatistics = true
(s) htmlCompressionStatistics = C:\Users\...\Documents\Java\NewBigBag\Convert-Kit\trunk\target/htmlcompressor/html-compression-statistics.txt
(s) javascriptHtmlSprite = true
(s) javascriptHtmlSpriteIntegrationFile = C:\Users\...\Documents\Java\NewBigBag\Convert-Kit\trunk/src/main/resources/html/integration.js
(s) javascriptHtmlSpriteTargetFile = C:\Users\JVerstry\Documents\Java\NewBigBag\Convert-Kit\trunk\target/htmlcompressor/html/integration.js
(s) jsCompressor = yui
(s) predefinedPreservePatterns = []
(s) preservePatternFiles = []
(s) preservePatterns = []
(s) removeComments = true
(s) removeFormAttributes = false
(s) removeHttpProtocol = false
(s) removeHttpsProtocol = false
(s) removeInputAttributes = false
(s) removeIntertagSpaces = true
(s) removeJavaScriptProtocol = false
(s) removeLinkAttributes = false
(s) removeMultiSpaces = true
(s) removeQuotes = false
(s) removeScriptAttributes = false
(s) removeStyleAttributes = false
(s) simpleBooleanAttributes = false
(s) simpleDoctype = false
(s) srcFolder = C:\Users\...\Documents\Java\NewBigBag\Convert-Kit\trunk/src/main/webapp/html
(s) targetFolder = C:\Users\...\Documents\Java\NewBigBag\Convert-Kit\trunk/src/main/webapp/result/html
(s) yuiCssLineBreak = -1
(s) yuiJsDisableOptimizations = false
(s) yuiJsLineBreak = -1
(s) yuiJsNoMunge = false
(s) yuiJsPreserveAllSemiColons = false
-- end configuration --
Compressing C:\Users\...\Documents\Java\NewBigBag\Convert-Kit\trunk/src/main/webapp/html
------------------------------------------------------------------------
BUILD FAILURE
------------------------------------------------------------------------
Total time: 2:01.151s
Finished at: Sun Jan 29 11:55:23 CET 2012
Final Memory: 16M/47M
------------------------------------------------------------------------
Failed to execute goal com.tunyk.mvn.plugins.htmlcompressor:htmlcompressor-maven-plugin:1.2:html (default) on project convertkit: Execution default of goal com.tunyk.mvn.plugins.htmlcompressor:htmlcompressor-maven-plugin:1.2:html failed. NullPointerException -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.tunyk.mvn.plugins.htmlcompressor:htmlcompressor-maven-plugin:1.2:html (default) on project convertkit: Execution default of goal com.tunyk.mvn.plugins.htmlcompressor:htmlcompressor-maven-plugin:1.2:html failed.
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:225)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:319)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default of goal com.tunyk.mvn.plugins.htmlcompressor:htmlcompressor-maven-plugin:1.2:html failed.
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:110)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
... 19 more
Caused by: java.lang.NullPointerException
at com.tunyk.mvn.plugins.htmlcompressor.HtmlCompressorMojo.execute(HtmlCompressorMojo.java:417)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
... 20 more
That is a bug of htmlcompressor-maven-plugin.
The fix has been committed and release 1.3 has been scheduled on Feb 5th.
With version 1.3 you'll see message "HTML compression was turned off." or "XML compression was turned off." in case of property "enabled" is set to false.
Related
I'd like to experiment scala on some unreliable macro. So I mimic a simple error in shapeless invocation:
import shapeless.Witness
val v = Witness(Random.nextInt())
Then I compile it with gradle build --info --stacktrace, expecting to find an exception that starts with 'shapeless.Witness' or something similar. Instead I got this:
> Task :common:compileTestScala
[Error] /home/peng/git-spike/scalaspike/common/src/test/scala/com/tribbloids/spike/shapeless_spike/RefinedType/Creation.scala:12: Expression scala.util.Random.nextInt() does not evaluate to a constant or a stable reference value
one error found
> Task :common:compileTestScala FAILED
5 actionable tasks: 1 executed, 4 up-to-date
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':common:compileTestScala'.
> Compilation failed
* Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':common:compileTestScala'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.lambda$executeIfValid$1(ExecuteActionsTaskExecuter.java:205)
at org.gradle.internal.Try$Failure.ifSuccessfulOrElse(Try.java:263)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeIfValid(ExecuteActionsTaskExecuter.java:203)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:184)
at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:114)
at org.gradle.api.internal.tasks.execution.FinalizePropertiesTaskExecuter.execute(FinalizePropertiesTaskExecuter.java:46)
at org.gradle.api.internal.tasks.execution.ResolveTaskExecutionModeExecuter.execute(ResolveTaskExecutionModeExecuter.java:62)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:57)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:56)
at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:36)
at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.executeTask(EventFiringTaskExecuter.java:77)
at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:55)
at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:52)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:416)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:406)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:165)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:250)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:158)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:102)
at org.gradle.internal.operations.DelegatingBuildOperationExecutor.call(DelegatingBuildOperationExecutor.java:36)
at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:52)
at org.gradle.execution.plan.LocalTaskNodeExecutor.execute(LocalTaskNodeExecutor.java:41)
at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:372)
at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:359)
at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:352)
at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:338)
at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.lambda$run$0(DefaultPlanExecutor.java:127)
at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.execute(DefaultPlanExecutor.java:191)
at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.executeNextNode(DefaultPlanExecutor.java:182)
at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.run(DefaultPlanExecutor.java:124)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
Caused by: org.gradle.api.internal.tasks.compile.CompilationFailedException: Compilation failed
at org.gradle.api.internal.tasks.scala.ZincScalaCompiler.execute(ZincScalaCompiler.java:151)
at org.gradle.api.internal.tasks.scala.ZincScalaCompilerFacade.execute(ZincScalaCompilerFacade.java:47)
at org.gradle.api.internal.tasks.scala.ZincScalaCompilerFacade.execute(ZincScalaCompilerFacade.java:32)
at org.gradle.api.internal.tasks.compile.daemon.AbstractDaemonCompiler$CompilerWorkAction.execute(AbstractDaemonCompiler.java:135)
at org.gradle.workers.internal.DefaultWorkerServer.execute(DefaultWorkerServer.java:63)
at org.gradle.workers.internal.AbstractClassLoaderWorker$1.create(AbstractClassLoaderWorker.java:47)
at org.gradle.workers.internal.AbstractClassLoaderWorker$1.create(AbstractClassLoaderWorker.java:41)
at org.gradle.internal.classloader.ClassLoaderUtils.executeInClassloader(ClassLoaderUtils.java:98)
at org.gradle.workers.internal.AbstractClassLoaderWorker.executeInClassLoader(AbstractClassLoaderWorker.java:41)
at org.gradle.workers.internal.IsolatedClassloaderWorker.execute(IsolatedClassloaderWorker.java:49)
at org.gradle.workers.internal.WorkerDaemonServer.execute(WorkerDaemonServer.java:84)
at org.gradle.process.internal.worker.request.WorkerAction$1.call(WorkerAction.java:129)
at org.gradle.process.internal.worker.child.WorkerLogEventListener.withWorkerLoggingProtocol(WorkerLogEventListener.java:41)
at org.gradle.process.internal.worker.request.WorkerAction.run(WorkerAction.java:126)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:182)
at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:164)
at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:412)
... 3 more
Caused by: Compilation failed
at sbt.internal.inc.AnalyzingCompiler.call(AnalyzingCompiler.scala:253)
at sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:122)
at sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:95)
at sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4(MixedAnalyzingCompiler.scala:91)
at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
at sbt.internal.inc.MixedAnalyzingCompiler.timed(MixedAnalyzingCompiler.scala:186)
at sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$3(MixedAnalyzingCompiler.scala:82)
at sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$3$adapted(MixedAnalyzingCompiler.scala:77)
at sbt.internal.inc.JarUtils$.withPreviousJar(JarUtils.scala:215)
at sbt.internal.inc.MixedAnalyzingCompiler.compileScala$1(MixedAnalyzingCompiler.scala:77)
at sbt.internal.inc.MixedAnalyzingCompiler.compile(MixedAnalyzingCompiler.scala:146)
at sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1(IncrementalCompilerImpl.scala:343)
at sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1$adapted(IncrementalCompilerImpl.scala:343)
at sbt.internal.inc.Incremental$.doCompile(Incremental.scala:120)
at sbt.internal.inc.Incremental$.$anonfun$compile$4(Incremental.scala:100)
at sbt.internal.inc.IncrementalCommon.recompileClasses(IncrementalCommon.scala:180)
at sbt.internal.inc.IncrementalCommon.cycle(IncrementalCommon.scala:98)
at sbt.internal.inc.Incremental$.$anonfun$compile$3(Incremental.scala:102)
at sbt.internal.inc.Incremental$.manageClassfiles(Incremental.scala:155)
at sbt.internal.inc.Incremental$.compile(Incremental.scala:92)
at sbt.internal.inc.IncrementalCompile$.apply(Compile.scala:75)
at sbt.internal.inc.IncrementalCompilerImpl.compileInternal(IncrementalCompilerImpl.scala:348)
at sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileIncrementally$1(IncrementalCompilerImpl.scala:301)
at sbt.internal.inc.IncrementalCompilerImpl.handleCompilationError(IncrementalCompilerImpl.scala:168)
at sbt.internal.inc.IncrementalCompilerImpl.compileIncrementally(IncrementalCompilerImpl.scala:248)
at sbt.internal.inc.IncrementalCompilerImpl.compile(IncrementalCompilerImpl.scala:74)
at org.gradle.api.internal.tasks.scala.ZincScalaCompiler.execute(ZincScalaCompiler.java:147)
... 21 more
How is this supposed to help me? I can only see the code of shapeless.Witness, not the entire sbt.internal.inc.AnalyzingCompiler. What should I do to see the error that can be related to the macro that actually reported the error?
UPDATE 1 On behalf of Dmytro Mitin I'd like to also attach my build configurations:
allprojects {
apply(plugin = "java")
apply(plugin = "java-library")
apply(plugin = "scala")
...
dependencies {
implementation("org.scala-lang:scala-compiler:${vs.scalaV}")
implementation("org.scala-lang:scala-library:${vs.scalaV}")
implementation("org.scala-lang:scala-reflect:${vs.scalaV}")
<vs.scalaV=2.12.11>
...
<witness is introduced in s submodule>
}
tasks {
val jvmTarget = JavaVersion.VERSION_1_8.toString()
withType<ScalaCompile> {
targetCompatibility = jvmTarget
scalaCompileOptions.loggingLevel = "debug"
scalaCompileOptions.additionalParameters = listOf(
"-encoding", "utf8",
"-unchecked",
"-deprecation",
"-feature",
"-Xfatal-warnings",
"-Xlog-implicits",
"-Yissue-debug"
)
}
}
}
UPDATE 2 on maven:
[ERROR] /home/peng/git-dev/scala-2.11/datapassports/spookystuff/core/src/test/scala/com/tribbloids/spookystuff/utils/WitnessSpike.scala:11: Expression scala.util.Random.nextInt() does not evaluate to a constant or a stable reference value
[ERROR] Witness(Random.nextInt())
[ERROR] ^
...
[ERROR] Failed to execute goal net.alchim31.maven:scala-maven-plugin:3.4.6:testCompile (scala-test-compile-first) on project spookystuff-core: Execution scala-test-compile-first of goal net.alchim31.maven:scala-maven-plugin:3.4.6:testCompile failed.: CompileFailed -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal net.alchim31.maven:scala-maven-plugin:3.4.6:testCompile (scala-test-compile-first) on project spookystuff-core: Execution scala-test-compile-first of goal net.alchim31.maven:scala-maven-plugin:3.4.6:testCompile failed.
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:190)
at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:186)
at java.util.concurrent.FutureTask.run (FutureTask.java:266)
at java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:511)
at java.util.concurrent.FutureTask.run (FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:624)
at java.lang.Thread.run (Thread.java:748)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution scala-test-compile-first of goal net.alchim31.maven:scala-maven-plugin:3.4.6:testCompile failed.
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:148)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:190)
at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:186)
at java.util.concurrent.FutureTask.run (FutureTask.java:266)
at java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:511)
at java.util.concurrent.FutureTask.run (FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:624)
at java.lang.Thread.run (Thread.java:748)
Caused by: sbt.compiler.CompileFailed
at sbt.compiler.AnalyzingCompiler.call (AnalyzingCompiler.scala:111)
at sbt.compiler.AnalyzingCompiler.compile (AnalyzingCompiler.scala:53)
at sbt.compiler.AnalyzingCompiler.compile (AnalyzingCompiler.scala:47)
at sbt.compiler.AggressiveCompile$$anonfun$3$$anonfun$compileScala$1$1.apply$mcV$sp (AggressiveCompile.scala:95)
at sbt.compiler.AggressiveCompile$$anonfun$3$$anonfun$compileScala$1$1.apply (AggressiveCompile.scala:95)
at sbt.compiler.AggressiveCompile$$anonfun$3$$anonfun$compileScala$1$1.apply (AggressiveCompile.scala:95)
at sbt.compiler.AggressiveCompile.sbt$compiler$AggressiveCompile$$timed (AggressiveCompile.scala:168)
at sbt.compiler.AggressiveCompile$$anonfun$3.compileScala$1 (AggressiveCompile.scala:94)
at sbt.compiler.AggressiveCompile$$anonfun$3.apply (AggressiveCompile.scala:142)
at sbt.compiler.AggressiveCompile$$anonfun$3.apply (AggressiveCompile.scala:84)
at sbt.inc.IncrementalCompile$$anonfun$doCompile$1.apply (Compile.scala:66)
at sbt.inc.IncrementalCompile$$anonfun$doCompile$1.apply (Compile.scala:64)
at sbt.inc.IncrementalCommon.cycle (IncrementalCommon.scala:32)
at sbt.inc.Incremental$$anonfun$1.apply (Incremental.scala:72)
at sbt.inc.Incremental$$anonfun$1.apply (Incremental.scala:71)
at sbt.inc.Incremental$.manageClassfiles (Incremental.scala:99)
at sbt.inc.Incremental$.compile (Incremental.scala:71)
at sbt.inc.IncrementalCompile$.apply (Compile.scala:54)
at sbt.compiler.AggressiveCompile.compile2 (AggressiveCompile.scala:159)
at sbt.compiler.AggressiveCompile.compile1 (AggressiveCompile.scala:68)
at com.typesafe.zinc.Compiler.compile (Compiler.scala:207)
at com.typesafe.zinc.Compiler.compile (Compiler.scala:189)
at com.typesafe.zinc.Compiler.compile (Compiler.scala:180)
at com.typesafe.zinc.Compiler.compile (Compiler.scala:171)
at sbt_inc.SbtIncrementalCompiler.compile (SbtIncrementalCompiler.java:94)
at scala_maven.ScalaCompilerSupport.incrementalCompile (ScalaCompilerSupport.java:320)
at scala_maven.ScalaCompilerSupport.compile (ScalaCompilerSupport.java:136)
at scala_maven.ScalaCompilerSupport.doExecute (ScalaCompilerSupport.java:116)
at scala_maven.ScalaMojoSupport.execute (ScalaMojoSupport.java:574)
at scala_maven.ScalaTestCompileMojo.execute (ScalaTestCompileMojo.java:50)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:190)
at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:186)
at java.util.concurrent.FutureTask.run (FutureTask.java:266)
at java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:511)
at java.util.concurrent.FutureTask.run (FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:624)
at java.lang.Thread.run (Thread.java:748)
Oops, equally useless. Can't believe I had high hope for it. Relevenat build plugin configuration looks like this:
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.4.6</version>
<executions>
<execution>
<id>scala-compile-first</id>
<phase>process-resources</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>scala-test-compile-first</id>
<phase>process-test-resources</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
<!--required for publishing to maven central-->
<execution>
<id>add-source</id>
<goals>
<goal>add-source</goal>
</goals>
</execution>
<execution>
<id>attach-scaladocs</id>
<goals>
<goal>doc-jar</goal>
</goals>
<configuration>
<args>
<!-- see https://github.com/dmlc/xgboost/issues/4000-->
<arg>-nobootcp</arg>
</args>
</configuration>
</execution>
</executions>
<configuration>
<scalaVersion>${scala.version}</scalaVersion>
<scalaCompatVersion>${scala.binary.version}</scalaCompatVersion>
<recompileMode>incremental</recompileMode>
<!--https://tpolecat.github.io/2017/04/25/scalac-flags.html-->
<args>
<arg>-target:jvm-${java.version}</arg>
<arg>-unchecked</arg>
<arg>-deprecation</arg>
<arg>-feature</arg>
<arg>-g:vars</arg>
<arg>-encoding</arg>
<arg>UTF-8</arg>
<arg>-Xlint</arg>
</args>
<javacArgs>
<javacArg>-source</javacArg>
<javacArg>${java.version}</javacArg>
<javacArg>-target</javacArg>
<javacArg>${java.version}</javacArg>
</javacArgs>
<excludes>
<exclude>**/.ipynb_checkpoints/*</exclude>
</excludes>
</configuration>
</plugin>
UPDATE 3 I finally tried on sbt, but apparently the macro stacktrace option cannot be enabled. This is the scalac configuration in sbt build file:
scalacOptions ++= Seq(
"-unchecked",
"-deprecation",
"-feature",
// "-Xfatal-warnings",
"-Xlint:poly-implicit-overload",
"-Xlint:option-implicit",
// "-Xlog-implicits",
// "-Xlog-implicit-conversions",
"-Yissue-debug"
)
scalacOptions in (Compile, doc) ++= Seq("-groups")
/** Enable for debugging */
testOptions in Test += Tests.Argument("-oF")
Then it shows even less information than maven & gradle:
> run
[warn] Credentials file /home/peng/.bintray/.credentials does not exist
[warn] Credentials file /home/peng/.ivy2/.sbtcredentials does not exist
[info] Compiling 235 Scala sources and 30 Java sources to /home/peng/git-release/spark-nlp/target/scala-2.11/classes...
[error] /home/peng/git-release/spark-nlp/src/main/scala/com/johnsnowlabs/collections/SearchTrie.scala:86: Expression scala.util.Random.nextInt() does not evaluate to a constant or a stable reference value
[error] Witness(Random.nextInt())
[error] ^
[warn] /home/peng/git-release/spark-nlp/src/main/scala/com/johnsnowlabs/ml/tensorflow/TensorflowSpell.scala:134: inferred existential type (org.tensorflow.Tensor[?0], org.tensorflow.Tensor[?0], org.tensorflow.Tensor[?0]) forSome { type ?0; type ?0; type ?0 }, which cannot be expressed by wildcards, should be enabled
... (skipping irrelevant warnings)
[warn] 9 warnings found
[error] one error found
[error] (compile:compileIncremental) Compilation failed
[error] Total time: 5 s, completed 28-Jul-2020 12:44:30 AM
>
>
>
> last run
>
>
Do I miss something in any of these build system?
Do other compiler errors give you useful stacktraces?
Stack traces are fundamentally a runtime thing: the only stacktrace you can have at compile time is the stacktrace within the compiler (e.g. the sbt.compiler package in the stack traces in the question).
In general, to debug macro issues, depending on the issue, you'll either:
Run the Scala compiler inside a debugger (there are instructions) if the macro in question is failing to expand
Dumping the generated code with the -Ymacro-debug-lite compiler option, which will give you the generated Scala code and the abstract syntax tree representation; this would be useful only in the case where the macro expands but either itself fails to compile or exhibits a runtime bug
I'm trying to generate a fully compiled kmodule with kie-maven-plugin. It works when all facts are defined in DRL, but fails when some facts are defined as Java POJOs.
In the same project:
Java fact (src\main\java\org\example\FactA.java):
package org.example;
public class FactA {
private String propA;
public FactA() { }
public FactA(String propA) {
this.propA = propA;
}
public String getPropA() {
return propA;
}
public void setPropA(String propA) {
this.propA = propA;
}
}
DRL Fact (src\main\resources\org\example\decB.drl):
package org.example
import org.example.FactA
declare FactB
factA: FactA
propB : String
end
POM:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<properties>
<generateModel>YES</generateModel>
<runtime.version>7.20.0.Final</runtime.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<groupId>org</groupId>
<artifactId>example</artifactId>
<version>1.0.0</version>
<packaging>kjar</packaging>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-bom</artifactId>
<version>${runtime.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.kie</groupId>
<artifactId>kie-api</artifactId>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-model-compiler</artifactId>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-canonical-model</artifactId>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-core</artifactId>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-compiler</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.kie</groupId>
<artifactId>kie-maven-plugin</artifactId>
<version>${runtime.version}</version>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
</project>
Output of mvn clean package
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------------------< org:example >-----------------------------
[INFO] Building example 1.0.0
[INFO] --------------------------------[ kjar ]--------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) # example ---
[INFO] Deleting C:\Projects\t\kie-maven-plugin-example\target
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) # example ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 3 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) # example ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
[INFO] Compiling 1 source file to C:\Projects\t\kie-maven-plugin-example\target\classes
[INFO]
[INFO] --- kie-maven-plugin:7.20.0.Final:generateModel (default-generateModel) # example ---
[INFO] Loading kie.conf from jar:file:/C:/Users/Dmitri/.m2/repository/org/drools/drools-core/7.20.0.Final/drools-core-7.20.0.Final.jar!/META-INF/kie.conf in classloader ClassRealm[extension>org.kie:kie-maven-plugin:7.20.0.Final, parent: sun.misc.Launcher$AppClassLoader#7852e922]
[INFO] Adding Service org.drools.core.io.impl.ResourceFactoryServiceImpl
[INFO] Adding Service org.drools.core.marshalling.impl.MarshallerProviderImpl
[INFO] Adding Service org.drools.core.concurrent.ExecutorProviderImpl
[INFO] Loading kie.conf from jar:file:/C:/Users/Dmitri/.m2/repository/org/drools/drools-compiler/7.20.0.Final/drools-compiler-7.20.0.Final.jar!/META-INF/kie.conf in classloader ClassRealm[extension>org.kie:kie-maven-plugin:7.20.0.Final, parent: sun.misc.Launcher$AppClassLoader#7852e922]
[INFO] Adding Service org.drools.compiler.kie.builder.impl.KieServicesImpl
[INFO] Adding Service org.drools.compiler.builder.impl.KnowledgeBuilderFactoryServiceImpl
[INFO] Loading kie.conf from jar:file:/C:/Users/Dmitri/.m2/repository/org/drools/drools-model-compiler/7.20.0.Final/drools-model-compiler-7.20.0.Final.jar!/META-INF/kie.conf in classloader ClassRealm[extension>org.kie:kie-maven-plugin:7.20.0.Final, parent: sun.misc.Launcher$AppClassLoader#7852e922]
[INFO] Adding Service org.drools.modelcompiler.CanonicalKieModuleProvider
[INFO] Loading kie.conf from jar:file:/C:/Users/Dmitri/.m2/repository/org/kie/kie-internal/7.20.0.Final/kie-internal-7.20.0.Final.jar!/META-INF/kie.conf in classloader ClassRealm[extension>org.kie:kie-maven-plugin:7.20.0.Final, parent: sun.misc.Launcher$AppClassLoader#7852e922]
[INFO] Adding Service org.kie.internal.services.KieAssemblersImpl
[INFO] Adding Service org.kie.internal.services.KieRuntimesImpl
[INFO] Adding Service org.kie.internal.services.KieWeaversImpl
[INFO] Adding Service org.kie.internal.services.KieBeliefsImpl
[INFO] Loading kie.conf from jar:file:/C:/Users/Dmitri/.m2/repository/org/drools/drools-decisiontables/7.20.0.Final/drools-decisiontables-7.20.0.Final.jar!/META-INF/kie.conf in classloader ClassRealm[extension>org.kie:kie-maven-plugin:7.20.0.Final, parent: sun.misc.Launcher$AppClassLoader#7852e922]
[INFO] Adding Service org.drools.decisiontable.DecisionTableProviderImpl
[INFO] Loading kie.conf from jar:file:/C:/Users/Dmitri/.m2/repository/org/drools/drools-scorecards/7.20.0.Final/drools-scorecards-7.20.0.Final.jar!/META-INF/kie.conf in classloader ClassRealm[extension>org.kie:kie-maven-plugin:7.20.0.Final, parent: sun.misc.Launcher$AppClassLoader#7852e922]
[INFO] Adding Service org.drools.scorecards.ScoreCardProviderImpl
[INFO] Loading kie.conf from jar:file:/C:/Users/Dmitri/.m2/repository/org/drools/kie-pmml/7.20.0.Final/kie-pmml-7.20.0.Final.jar!/META-INF/kie.conf in classloader ClassRealm[extension>org.kie:kie-maven-plugin:7.20.0.Final, parent: sun.misc.Launcher$AppClassLoader#7852e922]
[INFO] Adding Service +org.kie.pmml.assembler.PMMLAssemblerService
[INFO] Loading kie.conf from jar:file:/C:/Users/Dmitri/.m2/repository/org/jbpm/jbpm-bpmn2/7.20.0.Final/jbpm-bpmn2-7.20.0.Final.jar!/META-INF/kie.conf in classloader ClassRealm[extension>org.kie:kie-maven-plugin:7.20.0.Final, parent: sun.misc.Launcher$AppClassLoader#7852e922]
[INFO] Adding Service org.jbpm.bpmn2.BPMN2ProcessProviderImpl
[INFO] Adding Service org.jbpm.bpmn2.xml.XmlProcessDumperFactoryServiceImpl
[INFO] Loading kie.conf from jar:file:/C:/Users/Dmitri/.m2/repository/org/jbpm/jbpm-flow-builder/7.20.0.Final/jbpm-flow-builder-7.20.0.Final.jar!/META-INF/kie.conf in classloader ClassRealm[extension>org.kie:kie-maven-plugin:7.20.0.Final, parent: sun.misc.Launcher$AppClassLoader#7852e922]
[INFO] Adding Service org.jbpm.process.builder.ProcessBuilderFactoryServiceImpl
[INFO] Adding Service +org.jbpm.assembler.BPMN2AssemblerService
[INFO] Adding Service +org.jbpm.weaver.BPMN2WeaverService
[INFO] Adding Service +org.jbpm.assembler.DRFAssemblerService
[INFO] Adding Service +org.jbpm.weaver.DRFWeaverService
[INFO] Loading kie.conf from jar:file:/C:/Users/Dmitri/.m2/repository/org/jbpm/jbpm-flow/7.20.0.Final/jbpm-flow-7.20.0.Final.jar!/META-INF/kie.conf in classloader ClassRealm[extension>org.kie:kie-maven-plugin:7.20.0.Final, parent: sun.misc.Launcher$AppClassLoader#7852e922]
[INFO] Adding Service org.jbpm.marshalling.impl.ProcessMarshallerFactoryServiceImpl
[INFO] Adding Service org.jbpm.process.instance.ProcessRuntimeFactoryServiceImpl
[INFO] Loading kie.conf from jar:file:/C:/Users/Dmitri/.m2/repository/org/jbpm/jbpm-case-mgmt-cmmn/7.20.0.Final/jbpm-case-mgmt-cmmn-7.20.0.Final.jar!/META-INF/kie.conf in classloader ClassRealm[extension>org.kie:kie-maven-plugin:7.20.0.Final, parent: sun.misc.Launcher$AppClassLoader#7852e922]
[INFO] Adding Service org.jbpm.casemgmt.cmmn.CMMNCaseProviderImpl
[INFO] Adding Service +org.jbpm.casemgmt.cmmn.assembler.CMMNAssemblerService
[INFO] Loading kie.conf from jar:file:/C:/Users/Dmitri/.m2/repository/org/drools/drools-workbench-models-guided-dtable/7.20.0.Final/drools-workbench-models-guided-dtable-7.20.0.Final.jar!/META-INF/kie.conf in classloader ClassRealm[extension>org.kie:kie-maven-plugin:7.20.0.Final, parent: sun.misc.Launcher$AppClassLoader#7852e922]
[INFO] Adding Service org.drools.workbench.models.guided.dtable.backend.GuidedDecisionTableProviderImpl
[INFO] Loading kie.conf from jar:file:/C:/Users/Dmitri/.m2/repository/org/drools/drools-workbench-models-guided-template/7.20.0.Final/drools-workbench-models-guided-template-7.20.0.Final.jar!/META-INF/kie.conf in classloader ClassRealm[extension>org.kie:kie-maven-plugin:7.20.0.Final, parent: sun.misc.Launcher$AppClassLoader#7852e922]
[INFO] Adding Service org.drools.workbench.models.guided.template.backend.GuidedRuleTemplateProviderImpl
[INFO] Loading kie.conf from jar:file:/C:/Users/Dmitri/.m2/repository/org/drools/drools-workbench-models-guided-scorecard/7.20.0.Final/drools-workbench-models-guided-scorecard-7.20.0.Final.jar!/META-INF/kie.conf in classloader ClassRealm[extension>org.kie:kie-maven-plugin:7.20.0.Final, parent: sun.misc.Launcher$AppClassLoader#7852e922]
[INFO] Adding Service org.drools.workbench.models.guided.scorecard.backend.GuidedScoreCardProviderImpl
[INFO] Loading kie.conf from jar:file:/C:/Users/Dmitri/.m2/repository/org/optaplanner/optaplanner-core/7.20.0.Final/optaplanner-core-7.20.0.Final.jar!/META-INF/kie.conf in classloader ClassRealm[extension>org.kie:kie-maven-plugin:7.20.0.Final, parent: sun.misc.Launcher$AppClassLoader#7852e922]
[INFO] Adding Service +org.optaplanner.core.impl.solver.kie.KieSolverAssemblerService
[INFO] Loading kie.conf from jar:file:/C:/Users/Dmitri/.m2/repository/org/kie/kie-dmn-core/7.20.0.Final/kie-dmn-core-7.20.0.Final.jar!/META-INF/kie.conf in classloader ClassRealm[extension>org.kie:kie-maven-plugin:7.20.0.Final, parent: sun.misc.Launcher$AppClassLoader#7852e922]
[INFO] Adding Service +org.kie.dmn.core.assembler.DMNAssemblerService
[INFO] Adding Service +org.kie.dmn.core.runtime.DMNRuntimeService
[INFO] Adding Service +org.kie.dmn.core.weaver.DMNWeaverService
[INFO] Artifact not fetched from maven: org.drools:drools-bom:${runtime.version}. To enable the KieScanner you need kie-ci on the classpath
[ERROR] package org.example
public class FactB implements org.drools.core.factmodel.GeneratedFact, java.io.Serializable {
public FactB() {
}
public FactB(FactA factA, String propB) {
super();
this.factA = factA;
this.propB = propB;
}
#org.kie.api.definition.type.Position(value = 0)
private FactA factA;
public void setFactA(FactA factA) {
this.factA = factA;
}
public FactA getFactA() {
return factA;
}
#org.kie.api.definition.type.Position(value = 1)
private String propB;
public void setPropB(String propB) {
this.propB = propB;
}
public String getPropB() {
return propB;
}
#Override()
public String toString() {
return "FactB" + "( " + "factA=" + factA + ", " + "propB=" + propB + " )";
}
}
[ERROR] Unable to build KieBaseModel:defaultKieBase
CompilationProblemErrorResult: cannot find symbol
symbol: class FactA
location: package org.example
CompilationProblemErrorResult: cannot find symbol
symbol: class FactA
location: class org.example.FactB
CompilationProblemErrorResult: cannot find symbol
symbol: class FactA
location: class org.example.FactB
CompilationProblemErrorResult: cannot find symbol
symbol: class FactA
location: class org.example.FactB
CompilationProblemErrorResult: cannot find symbol
symbol: class FactA
location: class org.example.FactB
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.465 s
[INFO] Finished at: 2019-04-26T09:00:16-04:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.kie:kie-maven-plugin:7.20.0.Final:generateModel (default-generateModel) on project example: Execution default-generateModel of goal org.kie:kie-maven-plugin:7.20.0.Final:generateModel failed: Unable to get KieModule, Errors Existed: Error Messages:
[ERROR] Message [id=1, kieBase=defaultKieBase, level=ERROR, path=null, line=5, column=0
[ERROR] text=cannot find symbol
[ERROR] symbol: class FactA
[ERROR] location: package org.example]
[ERROR] Message [id=2, kieBase=defaultKieBase, level=ERROR, path=null, line=12, column=0
[ERROR] text=cannot find symbol
[ERROR] symbol: class FactA
[ERROR] location: class org.example.FactB]
[ERROR] Message [id=3, kieBase=defaultKieBase, level=ERROR, path=null, line=19, column=0
[ERROR] text=cannot find symbol
[ERROR] symbol: class FactA
[ERROR] location: class org.example.FactB]
[ERROR] Message [id=4, kieBase=defaultKieBase, level=ERROR, path=null, line=21, column=0
[ERROR] text=cannot find symbol
[ERROR] symbol: class FactA
[ERROR] location: class org.example.FactB]
[ERROR] Message [id=5, kieBase=defaultKieBase, level=ERROR, path=null, line=25, column=0
[ERROR] text=cannot find symbol
[ERROR] symbol: class FactA
[ERROR] location: class org.example.FactB]
[ERROR] ---
[ERROR] Warning Messages:
[ERROR] ---
[ERROR] Info Messages:
[ERROR]
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException
It's probably a bug in the generation of declared types with the executable model.
Can you kindly post your reproducer here?
https://issues.jboss.org/projects/DROOLS/issues
In the meanwhile, as a workaround, can you try use the fully qualified name while using the class in the declared type?
package org.example
declare FactB
factA: org.example.FactA
propB : String
end
I've tried this against current master and it works.
Thanks for your help
It was a bug fixed here
https://github.com/kiegroup/drools/commit/c36f3ebf1f02e54742c8b4056e7b64bb5deaed07
Thanks for reporting
I am using scalatest as my testing framework, here is my test code :
import org.scalatest.FunSuite
class SampleTest extends FunSuite{
test("hello") {
println(s"sdfsf")
}
}
build.sbt settings
val scalatestJS = libraryDependencies += "org.scalatest" %%% "scalatest" % Version.scalatest % Test
val scalatestJSSettings = Seq(
scalatestJS,
scalaJSStage in Global := FastOptStage,
// scalaJSStage in Global := FullOptStage,
// jsDependencies += RuntimeDOM,
// jsDependencies += ProvidedJS / "test-bundle.js" % Test,
jsEnv in Test := new PhantomJS2Env(scalaJSPhantomJSClassLoader.value, addArgs = Seq("--web-security=no"))
// jsEnv in Test := new NodeJSEnv()
)
Debug out :
[debug] Scala compilation took 0.961938628 s
[debug] Invalidating client/SampleTest.scala...
[debug] Invalidating (transitively) by inheritance from client/SampleTest.scala...
[debug] Initial set of included nodes: Set(client/SampleTest.scala)
[debug] Invalidated by transitive inheritance dependency: Set(client/SampleTest.scala)
[debug] The client/SampleTest.scala source file has the following implicit definitions changed:
[debug] unconstrainedEquality, convertToEqualizer.
[debug] All member reference dependencies will be considered within this context.
[debug] New invalidations:
[debug] Set()
[debug] Initial set of included nodes: Set()
[debug] Previously invalidated, but (transitively) depend on new invalidations:
[debug] Set()
[debug] All newly invalidated sources after taking into account (previously) recompiled sources:Set()
[debug] Copy resource mappings:
[debug]
[info] Fast optimizing client/assets/client-test-fastopt.js
[debug] Linker: Compute reachability: 710892 us
[debug] Linker: Assemble LinkedClasses: 445560 us
[debug] Basic Linking: 1168893 us
[debug] Inc. optimizer: Batch mode: true
[debug] Inc. optimizer: Incremental part: 127681 us
[debug] Inc. optimizer: Optimizing 11793 methods.
[debug] Inc. optimizer: Optimizer part: 5987357 us
[debug] Inc. optimizer: 6140114 us
[debug] Refiner: Compute reachability: 243271 us
[debug] Refiner: Assemble LinkedClasses: 27389 us
[debug] Refiner: 272567 us
[debug] Emitter: Class tree cache stats: reused: 0 -- invalidated: 1375
[debug] Emitter: Method tree cache stats: resued: 0 -- invalidated: 6643
[debug] Emitter (write output): 1353125 us
[debug] Global IR cache stats: reused: 0 -- invalidated: 130 -- trees read: 1748
[debug] Loading JSEnv with linked file client/assets/client-test-fastopt.js
org.scalajs.jsenv.ExternalJSEnv$NonZeroExitException: PhantomJS2 exited with code 2
at org.scalajs.jsenv.ExternalJSEnv$AbstractExtRunner.waitForVM(ExternalJSEnv.scala:107)
at org.scalajs.jsenv.ExternalJSEnv$ExtRunner.run(ExternalJSEnv.scala:156)
at org.scalajs.sbtplugin.FrameworkDetector.detect(FrameworkDetector.scala:66)
at org.scalajs.sbtplugin.ScalaJSPluginInternal$$anonfun$60.apply(ScalaJSPluginInternal.scala:737)
at org.scalajs.sbtplugin.ScalaJSPluginInternal$$anonfun$60.apply(ScalaJSPluginInternal.scala:720)
at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:40)
at sbt.std.Transform$$anon$4.work(System.scala:63)
at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:226)
at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:226)
at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
at sbt.Execute.work(Execute.scala:235)
at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:226)
at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:226)
at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:159)
at sbt.CompletionService$$anon$2.call(CompletionService.scala:28)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
[error] (client/test:loadedTestFrameworks) org.scalajs.jsenv.ExternalJSEnv$NonZeroExitException: PhantomJS2 exited with code 2
[error] Total time: 15 s, completed May 20, 2016 12:20:29 AM
Note : This is used to work fine but not anymore :s
Edit :
ScalaTest : 3.0.0-M15
ScalaJS : 0.6.9
Scala : 2.11.8
Phantom JS : 2.0.0
In my code i have a class which extends js class
#ScalaJSDefined
class MyLab(container : dom.Node) extends JSLab(container) {... }
even though i am not using this class in my tests,looks like source code generated for this line is some how looking for JSLab in global! which causes crash of phantomjs. Interestingly tests are executing fine on Rhino :s. anyhow i added JSLab as test dependency and error gone.
I don't know whom to blame here , whether its stupid developer(me) who went in different direction while solving problem or scala.js for not helpful in why phantomjs crashed :s
I've been following Manning's Grails In Action, but their section on configuring data sources is woefully out-of-date for Grails 3.0.3.
My intention is to convert from the default data source of H2 to MongoDB version 3.0.2. Google searches have yielded conflicting results -- many answers are often for earlier versions of Grails, which used 'BuildConfig.groovy' and 'DataSources.groovy' in order to establish plug-ins and data sources.
I've downloaded the 3.0.2 JDBC for MongoDB and stored it in various folders (i.e. the root of the application, a created /lib/ folder, and in /grails-app/conf/) without success.
My application.yml file reads:
---
grails:
profile: web
codegen:
defaultPackage: qotd
info:
app:
name: '#info.app.name#'
version: '#info.app.version#'
grailsVersion: '#info.app.grailsVersion#'
spring:
groovy:
template:
check-template-location: false
---
grails:
mime:
disable:
accept:
header:
userAgents:
- Gecko
- WebKit
- Presto
- Trident
types:
all: '*/*'
atom: application/atom+xml
css: text/css
csv: text/csv
form: application/x-www-form-urlencoded
html:
- text/html
- application/xhtml+xml
js: text/javascript
json:
- application/json
- text/json
multipartForm: multipart/form-data
rss: application/rss+xml
text: text/plain
hal:
- application/hal+json
- application/hal+xml
xml:
- text/xml
- application/xml
urlmapping:
cache:
maxsize: 1000
controllers:
defaultScope: singleton
converters:
encoding: UTF-8
views:
default:
codec: html
gsp:
encoding: UTF-8
htmlcodec: xml
codecs:
expression: html
scriptlets: html
taglib: none
staticparts: none
---
hibernate:
cache:
queries: false
use_second_level_cache: true
use_query_cache: false
region.factory_class: 'org.hibernate.cache.ehcache.EhCacheRegionFactory'
dataSource:
pooled: true
jmxExport: true
host: 'localhost'
port: 27017
driverClassName: mongodb-driver-3.0.2.jar
databaseName: 'test_db'
environments:
development:
dataSource:
dbCreate: create
url: jdbc:mongodb://localhost:27017
test:
dataSource:
dbCreate: update
url: jdbc:mongodb://localhost:27017
production:
dataSource:
dbCreate: update
url: jdbc:mongodb://localhost:27017
properties:
jmxEnabled: true
initialSize: 5
maxActive: 50
minIdle: 5
maxIdle: 25
maxWait: 10000
maxAge: 600000
timeBetweenEvictionRunsMillis: 5000
minEvictableIdleTimeMillis: 60000
validationQuery: SELECT 1
validationQueryTimeout: 3
validationInterval: 15000
testOnBorrow: true
testWhileIdle: true
testOnReturn: false
jdbcInterceptors: ConnectionState
defaultTransactionIsolation: 2 # TRANSACTION_READ_COMMITTED
My build.gradle file reads:
buildscript {
ext {
grailsVersion = project.grailsVersion
}
repositories {
mavenLocal()
maven { url "https://repo.grails.org/grails/core" }
}
dependencies {
classpath "org.grails:grails-gradle-plugin:$grailsVersion"
classpath 'com.bertramlabs.plugins:asset-pipeline-gradle:2.1.1'
}
}
plugins {
id "io.spring.dependency-management" version "0.5.2.RELEASE"
}
version "0.1"
group "qotd"
apply plugin: "spring-boot"
apply plugin: "war"
apply plugin: "asset-pipeline"
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: "org.grails.grails-web"
apply plugin: "org.grails.grails-gsp"
ext {
grailsVersion = project.grailsVersion
gradleWrapperVersion = project.gradleWrapperVersion
}
assets {
minifyJs = true
minifyCss = true
}
repositories {
mavenLocal()
maven { url "https://repo.grails.org/grails/core" }
}
dependencyManagement {
imports {
mavenBom "org.grails:grails-bom:$grailsVersion"
}
applyMavenExclusions false
}
dependencies {
compile "org.springframework.boot:spring-boot-starter-logging"
compile "org.springframework.boot:spring-boot-starter-actuator"
compile "org.springframework.boot:spring-boot-autoconfigure"
compile "org.springframework.boot:spring-boot-starter-tomcat"
compile "org.grails:grails-dependencies"
compile "org.grails:grails-web-boot"
compile 'org.mongodb:mongodb-driver:3.0.2'
compile "org.grails.plugins:hibernate"
compile "org.grails.plugins:cache"
compile "org.hibernate:hibernate-ehcache"
runtime "org.grails.plugins:asset-pipeline"
runtime "org.grails.plugins:scaffolding"
testCompile "org.grails:grails-plugin-testing"
testCompile "org.grails.plugins:geb"
// Note: It is recommended to update to a more robust driver (Chrome, Firefox etc.)
testRuntime 'org.seleniumhq.selenium:selenium-htmlunit-driver:2.44.0'
console "org.grails:grails-console"
}
task wrapper(type: Wrapper) {
gradleVersion = gradleWrapperVersion
}
... and finally, the actual stack trace when I try to execute $ grails run-app is:
java.util.concurrent.ExecutionException: org.gradle.tooling.BuildException: Could not execute build using Gradle distribution 'https://services.gradle.org/distributions/gradle-2.3-bin.zip'.
at java_util_concurrent_Future$get.call(Unknown Source)
at run-app.run(run-app.groovy:90)
at org.grails.cli.profile.commands.script.GroovyScriptCommand.handle(GroovyScriptCommand.groovy:152)
at org.grails.cli.profile.DefaultProfile.handleCommand(DefaultProfile.groovy:177)
at org.grails.cli.GrailsCli.handleCommand(GrailsCli.groovy:239)
at org.grails.cli.GrailsCli.handleCommand(GrailsCli.groovy:220)
at org.grails.cli.GrailsCli.execute(GrailsCli.groovy:198)
at org.grails.cli.GrailsCli.main(GrailsCli.groovy:99)
Caused by: org.gradle.tooling.BuildException: Could not execute build using Gradle distribution 'https://services.gradle.org/distributions/gradle-2.3-bin.zip'.
at org.gradle.tooling.internal.consumer.ResultHandlerAdapter.onFailure(ResultHandlerAdapter.java:57)
at org.gradle.tooling.internal.consumer.async.DefaultAsyncConsumerActionExecutor$1$1.run(DefaultAsyncConsumerActionExecutor.java:57)
at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:64)
at org.gradle.tooling.internal.consumer.BlockingResultHandler.getResult(BlockingResultHandler.java:46)
at org.gradle.tooling.internal.consumer.DefaultBuildLauncher.run(DefaultBuildLauncher.java:71)
at org.grails.cli.gradle.GradleUtil$_runBuildWithConsoleOutput_closure4.doCall(GradleUtil.groovy:109)
at org.grails.cli.gradle.GradleUtil$_withProjectConnection_closure2.doCall(GradleUtil.groovy:89)
at org.grails.cli.gradle.GradleUtil$_withProjectConnection_closure2.call(GradleUtil.groovy)
at grails.io.support.SystemOutErrCapturer.withNullOutput(SystemOutErrCapturer.groovy:64)
at org.grails.cli.gradle.GradleUtil.withProjectConnection(GradleUtil.groovy:88)
at org.grails.cli.gradle.GradleUtil.runBuildWithConsoleOutput(GradleUtil.groovy:104)
at org.grails.cli.gradle.GradleInvoker.invokeMethod(GradleInvoker.groovy:50)
at org.grails.cli.gradle.GradleAsyncInvoker$_invokeMethod_closure2.doCall(GradleAsyncInvoker.groovy:51)
at org.grails.cli.gradle.GradleAsyncInvoker$_invokeMethod_closure2.doCall(GradleAsyncInvoker.groovy)
Caused by: org.gradle.internal.exceptions.LocationAwareException: Execution failed for task ':bootRun'.
at org.gradle.initialization.DefaultExceptionAnalyser.transform(DefaultExceptionAnalyser.java:77)
at org.gradle.initialization.MultipleBuildFailuresExceptionAnalyser.transform(MultipleBuildFailuresExceptionAnalyser.java:47)
at org.gradle.initialization.StackTraceSanitizingExceptionAnalyser.transform(StackTraceSanitizingExceptionAnalyser.java:30)
at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:108)
at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:86)
at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:80)
at org.gradle.tooling.internal.provider.BuildModelAction.run(BuildModelAction.java:43)
at org.gradle.tooling.internal.provider.BuildModelAction.run(BuildModelAction.java:30)
at org.gradle.tooling.internal.provider.ConfiguringBuildAction.run(ConfiguringBuildAction.java:119)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:36)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:26)
at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:48)
at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:37)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:26)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.exec.RequestStopIfSingleUsedDaemon.execute(RequestStopIfSingleUsedDaemon.java:34)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:74)
at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:72)
at org.gradle.util.Swapper.swap(Swapper.java:38)
at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:72)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.health.DaemonHealthTracker.execute(DaemonHealthTracker.java:47)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:60)
at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:71)
at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.health.HintGCAfterBuild.execute(HintGCAfterBuild.java:41)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:50)
at org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:246)
at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:64)
Caused by: org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':bootRun'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:42)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53)
at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
at org.gradle.api.internal.AbstractTask.executeWithoutThrowingTaskFailure(AbstractTask.java:306)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.executeTask(AbstractTaskPlanExecutor.java:79)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:63)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:51)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:23)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:88)
at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:29)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:62)
at org.gradle.execution.DefaultBuildExecuter.access$200(DefaultBuildExecuter.java:23)
at org.gradle.execution.DefaultBuildExecuter$2.proceed(DefaultBuildExecuter.java:68)
at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:62)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:55)
at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:149)
at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:106)
... 34 more
Caused by: org.gradle.process.internal.ExecException: Process 'command '/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.85.x86_64/jre/bin/java'' finished with non-zero exit value 1
at org.gradle.process.internal.DefaultExecHandle$ExecResultImpl.assertNormalExitValue(DefaultExecHandle.java:365)
at org.gradle.process.internal.DefaultJavaExecAction.execute(DefaultJavaExecAction.java:31)
at org.gradle.api.tasks.JavaExec.exec(JavaExec.java:60)
at org.springframework.boot.gradle.run.BootRunTask.exec(BootRunTask.java:58)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:63)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.doExecute(AnnotationProcessingTaskFactory.java:218)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:211)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:200)
at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:585)
at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:568)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
... 57 more
| Error Failed to start server
Any help would be greatly appreciated; many hours have been spent slamming my head against my desk and finding unhelpful search results.
Yeah, it's a challenge finding up-to-date documentation for configuring Grails 3.0 to use MongoDB. The solution below was cobbled together from various sources.
build.gradle
dependencies {
...
compile "org.grails.plugins:mongodb"
...
}
You do not need to manually download and install any JDBC files.
grails-app/conf/application.yml
environments:
development:
grails:
mongodb:
connectionString: "mongodb://localhost:27017/project-db"
grails-app/domain/com/example/Book.groovy
package com.example
import org.bson.types.ObjectId
class Book {
ObjectId id
String title
static mapWith = "mongo"
}
I've been successfully using this approach since Grails 3.0.1, and it's still working with 3.0.4.
Dem Pilafian is great and correct. Mine is just slightly different. You can leave out the mapping in your classes and rely on mongodb to directly store your objects. All you need to do is remove hibernate from your project.
Using Grails 3.1.7
build.gradle
dependencies {
compile "org.grails.plugins:mongodb"
//compile "org.grails.plugins:hibernate4"
//compile "org.hibernate:hibernate-ehcache"
//runtime "com.h2database:h2"
}
I've commented out the hibernate and h2 dependencies. You can delete them entirely of course, if you use only mongodb.
grails-app/conf/application.yml
environments:
development:
grails:
mongodb:
host: "hostname"
port: 27017
databaseName: development
In the application.yml you need to remove the hibernate: section and the driverClassName: org.h2.Driver.
For more background information as well as additional configuration options, refer to: GORM Grails MongoDB
This way, you will bypass hibernate completely and don't need to define a mapping in your classes. Your objects will be directly stored as structured documents in mongo.
I run my scalatest from sbt, and the output gets mixed up - scalatest prints all the test run, and comments to them, and somewhere in the middle it prints the statistics:
> test
[info] Compiling 1 Scala source to /home/platon/Tor/scala-dojo-02/target/scala-2.9.1/classes...
[info] FunsWithListsTests:
[info] - should return list of labels
[info] - should return the average rating of games belonging to Zenga
[info] - should return the total ratings of all games
[info] - should return the total ratings of EA games *** FAILED ***
[info] 0 did not equal 170 (FunsWithListsTests.scala:35)
[error] Failed: : Total 8, Failed 5, Errors 0, Passed 3, Skipped 0
[info] - should increase all games rating by 10 *** FAILED ***
[error] Failed tests:
[error] dojo.FunsWithListsTests
[info] List() did not equal List(Game(Activision,40), Game(Zenga,70), Game(Zenga,20), Game(EA,70), Game(EA,120)) (FunsWithListsTests.scala:40)
[info] - should decrease all Zenga games rating by 10 *** FAILED ***
[info] List() did not equal List(Game(Activision,30), Game(Zenga,50), Game(Zenga,0), Game(EA,60), Game(EA,110)) (FunsWithListsTests.scala:45)
[info] - should create function to find Activision games *** FAILED ***
[info] List(Game(Activision,30), Game(Zenga,60), Game(Zenga,10), Game(EA,60), Game(EA,110)) did not equal List(Game(Activision,30)) (FunsWithListsTests.scala:50)
[info] - should return a List of tuples consisting of game label and game *** FAILED ***
[info] List() did not equal List((ACTIVISION,Game(Activision,30)), (ZENGA,Game(Zenga,60)), (ZENGA,Game(Zenga,10)), (EA,Game(EA,60)), (EA,Game(EA,110))) (FunsWithListsTests.scala:56)
[error] {file:/home/platon/Tor/scala-dojo-02/}default-940f03/test:test: Tests unsuccessful
[error] Total time: 1 s, completed Mar 20, 2012 9:27:13 AM
It seems that if I would accumulate a great number of tests, searching for those stats and failed tests would become a pain.
Is there a way to fix this?
It looks to me the reason for that is that SBT by default executes the tests in parallel, the same way maven-surefire-plugin does.
As it is explained in ScalaTest wiki, this can be solved by:
Disable Parallel Execution of Tests
By default, sbt runs all tasks in parallel. Because each test is mapped to a task, tests are also run in parallel by default. To disable parallel execution of tests:
parallelExecution in Test := false
Have the same issue and solved it by saving logs into separate files. Not ideal, but good for CI, especially in case of long-running integration tests. How I did it:
Create a special directory for logs (for example, at the end of build.sbt):
lazy val logDirectory = taskKey[File]("A directory for logs")
logDirectory := {
val r = target.value / "logs"
IO.createDirectory(r)
r
}
[Optionally] Specify a file for a summary information in a project:
testOptions in test += Tests.Argument(
TestFrameworks.ScalaTest, "-fW", (logDirectory.value / "summary.log").toString
)
W disables colors
Create a group for each test. Each group must run a test in a forked JVM with special arguments:
testGrouping in test := testGrouping.value.flatMap { group =>
group.tests.map { suite =>
val fileName = {
// foo.bar.baz.TestSuite -> f.b.b.TestSuite
val parts = suite.name.split('.')
(parts.init.map(_.substring(0, 1)) :+ parts.last).mkString(".")
}
val forkOptions = ForkOptions(
bootJars = Nil,
javaHome = javaHome.value,
connectInput = connectInput.value,
outputStrategy = outputStrategy.value,
runJVMOptions = javaOptions.value ++ Seq(
"-Dour.logging.appender=FILE",
s"-Dour.logging.dir=${logDirectory.value / fileName}"
),
workingDirectory = Some(baseDirectory.value),
envVars = envVars.value
)
group.copy(
name = suite.name,
runPolicy = Tests.SubProcess(forkOptions),
tests = Seq(suite)
)
}
}
Note, we can tell the logback, where we save our logs through our.logging.appender and our.logging.dir
Create a configuration for logging (test/resources/logback-test.xml):
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<target>System.out</target>
<encoder>
<pattern>%date{yyyy-MM-dd HH:mm:ss} %-5level [%thread] %logger{26} - %msg%n</pattern>
</encoder>
</appender>
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>${our.logging.dir}/test.log</file>
<append>false</append>
<encoder>
<pattern>%date{yyyy-MM-dd HH:mm:ss.SSS} %-5level [%thread] %logger{26} - %msg%n</pattern>
</encoder>
</appender>
<root level="TRACE">
<appender-ref ref="${our.logging.appender}"/>
</root>
</configuration>
That's all.