Commit Graph

15 Commits

Author SHA1 Message Date
Ethan Atkins 4698f388e9 Remove lint warnings in sbt build
There were a number of unused key lint warnings when loading the sbt
build. In the case of `fork in compile` and `crossVersion in update`, it
wasn't clear that these were actually used, so I removed those settings.
The others seemed to be used so I just added them to the exclude list.

To make this work with legacy versions of sbt, I redefined the
excludeLintKeys key. Once we update the build.properties to a 1.4.x
version, we can drop the `val excludeLint` definition and replace
`excludeLint` with `excludeLintKeys`.

Side note: ++= does not work with excludeLintKeys which is why I used +=
for the excludes.
2020-07-27 09:37:53 -07:00
Eugene Yokota 72aa0780fc Format build.sbt 2020-02-14 00:06:34 -05:00
Eugene Yokota 02152cc41b Refactor server test
This refactors the server test to reuse the server instance for the tests against the same build.
2020-02-13 23:31:09 -05:00
Charles O'Farrell 67a3eca698 Use hedgehog in ParseKey, Delegates, and ParserSpec test 2019-09-30 01:52:57 -04:00
Ethan Atkins a5db9e86d7 Rename typesafe release resolver in sbt build
I was still seeing a number of warnings in the sbt project itself in
spite of 9bb88cd342. This made those go
away.
2019-07-09 14:29:44 -07:00
Eugene Yokota 467d653efb Bump up test frameworks used in scripted tests
This is in part to test these on JDK 11 by bumping tests to Scala 2.12.7.
2018-09-29 23:19:49 -04:00
xuwei-k f01ff3dd03 simplify build settings. sbt 1.x no longer support old scala versions 2018-07-10 11:51:14 +09:00
Seth Tisue f5d51bf387 be 2.13 friendly
for the Scala 2.13 community build
2017-08-12 07:35:26 -07:00
jvican 2b12721a68
Add fully-fledged macro check for value inside if
`.value` inside the if of a regular task is unsafe. The wrapping task
will always execute the value, no matter what the if predicate yields.

This commit adds the infrastructure to lint code for every sbt DSL
macro. It also adds example of neg tests that check that the DSL checks
are in place.

The sbt checks yield error for this specific case because we may want to
explore changing this behaviour in the future. The solutions to this are
straightforward and explained in the error message, that looks like
this:

```
EXPECTED: The evaluation of `fooNeg` happens always inside a regular task.

PROBLEM: `fooNeg` is inside the if expression of a regular task.
  Regular tasks always evaluate task inside the bodies of if expressions.

SOLUTION:
  1. If you only want to evaluate it when the if predicate is true, use a dynamic task.
  2. Otherwise, make the static evaluation explicit by evaluating `fooNeg` outside the if expression.
```

Aside from those solutions, this commit also adds a way to disable any
DSL check by using the new `sbt.unchecked` annotation. This annotation,
similar to `scala.annotation.unchecked` disables compiler output. In our
case, it will disable any task dsl check, making it silent.

Examples of positive checks have also been added.

There have been only two places in `Defaults.scala` where this check has
made compilation fail.

The first one is inside `allDependencies`. To ensure that we still have
static dependencies for `allDependencies`, I have hoisted up the value
invocation outside the if expression. We may want to explore adding a
dynamic task in the future, though. We are doing unnecessary work there.

The second one is inside `update` and is not important because it's not
exposed to the user. We use a `taskDyn`.
2017-05-25 15:33:00 +02:00
jvican b4299e7f34
Add check of task invocation inside `if`
This commit adds the first version of the checker that will tell users
if they are doing something wrong.

The first version warns any user that write `.value` inside an if
expression.

As the test integration is not yet working correctly and messages are
swallowed, we have to println to get info from the test.
2017-05-24 17:27:18 +02:00
Dale Wijnand 0b33c195ef
Upgrade the build to sbt 1.0.0-M5
Some plugins remain commented out, for now.

sbt-doge is no longer needed because a variant of it has been folded
into sbt 1.

For some reason scripted requires src/doc jars of sbt, so switch back to
using `publishAll` rather than `publishLocalBinAll`. :(

Also, the sys.prop change in scripted is to force log4j2 to not use a
thread context classloader, and avoid the following:

    ERROR StatusLogger Unable to create custom ContextSelector. Falling back to default.
     java.lang.ClassCastException: Cannot cast org.apache.logging.log4j.core.async.AsyncLoggerContextSelector to org.apache.logging.log4j.core.selector.ContextSelector
    	at java.lang.Class.cast(Class.java:3369)
    	at org.apache.logging.log4j.util.LoaderUtil.newCheckedInstanceOf(LoaderUtil.java:201)
    	at org.apache.logging.log4j.util.LoaderUtil.newCheckedInstanceOfProperty(LoaderUtil.java:226)
    	at org.apache.logging.log4j.core.impl.Log4jContextFactory.createContextSelector(Log4jContextFactory.java:97)
    	at org.apache.logging.log4j.core.impl.Log4jContextFactory.<init>(Log4jContextFactory.java:58)
    	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    	at java.lang.Class.newInstance(Class.java:442)
    	at org.apache.logging.log4j.LogManager.<clinit>(LogManager.java:94)
    	at org.apache.logging.log4j.spi.ThreadContextMapFactory.createThreadContextMap(ThreadContextMapFactory.java:73)
    	at org.apache.logging.log4j.ThreadContext.init(ThreadContext.java:223)
    	at org.apache.logging.log4j.ThreadContext.<clinit>(ThreadContext.java:202)
    	at org.apache.logging.log4j.core.impl.ContextDataInjectorFactory.createDefaultInjector(ContextDataInjectorFactory.java:83)
    	at org.apache.logging.log4j.core.impl.ContextDataInjectorFactory.createInjector(ContextDataInjectorFactory.java:67)
    	at org.apache.logging.log4j.core.lookup.ContextMapLookup.<init>(ContextMapLookup.java:34)
    	at org.apache.logging.log4j.core.lookup.Interpolator.<init>(Interpolator.java:117)
    	at org.apache.logging.log4j.core.config.AbstractConfiguration.<init>(AbstractConfiguration.java:125)
    	at org.apache.logging.log4j.core.config.DefaultConfiguration.<init>(DefaultConfiguration.java:46)
    	at org.apache.logging.log4j.core.layout.PatternLayout$Builder.build(PatternLayout.java:650)
    	at org.apache.logging.log4j.core.layout.PatternLayout.createDefaultLayout(PatternLayout.java:487)
    	at sbt.internal.util.ConsoleAppender.<init>(ConsoleAppender.scala:245)
    	at sbt.internal.util.ConsoleAppender$.apply(ConsoleAppender.scala:196)
    	at sbt.internal.util.ConsoleLogger.<init>(ConsoleAppender.scala:42)
    	at sbt.internal.util.ConsoleLogger$.apply(ConsoleAppender.scala:34)
    	at sbt.test.ScriptedRunner.run(ScriptedTests.scala:221)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.lang.reflect.Method.invoke(Method.java:498)
    	at Scripted$.doScripted(Scripted.scala:125)
    	at $0483e89d182e9d240274$.$anonfun$scriptedTask$5(build.sbt:301)
2017-05-11 09:44:42 +01:00
Eugene Yokota da046791e0 Apply Scalafmt formatting 2017-04-21 04:48:31 -04:00
Dale Wijnand 0dcb57b587
Remove warnings in the build setup 2017-03-29 14:43:41 +01:00
Eugene Yokota f65712e90d Fix build 2015-02-02 22:44:02 -05:00
Eugene Yokota 5ce7c5aaca Fixing cross building 2014-12-18 17:40:20 -05:00