Backwards settings in sbt (allowInsecureProtocol) - sbt

I'm trying create a global setting for publishTo. The problem I have is that our repository is only configured for http not https.
As of sbt 1.3 I need to add allowInsecureProtocol to the setting, however since this is not part of the sbt 1.2 API I cannot have a setting which is used in 1.2 and 1.3, which breaks any projects which have yet to migrate to 1.3.
Is is possible to configure this conditionally. e.g. .sbt/1.2/global.sbt and .sbt/1.3/global.sbt.

Probably not recommended but I have managed to hack things with reflection.
val hacked = try {
classOf[MavenRepository]
.getMethod("withAllowInsecureProtocol", classOf[Boolean])
.invoke(repo, true.asInstanceOf[AnyRef])
.asInstanceOf[MavenRepository]
} catch { case _: java.lang.NoSuchMethodException => repo }

Related

Unable to build cordapp with accounts dependencies

I was able to build a cordapp using Accounts by following the steps at https://github.com/corda/accounts.
This cordapp was building and running until 03/16/2020, but since 03/20/2020 I am seeing errors in my CI builds because https://ci-artifactory.corda.r3cev.com/artifactory/corda-lib-dev/com/r3/corda/lib/accounts/accounts-contracts/1.0-RC04/accounts-contracts-1.0-RC04.jar cannot be accessed. I get a 409 response now, how can I resolve this?
{
"errors" : [ {
"status" : 409,
"message" : "The repository 'corda-lib-dev' rejected the resolution of an artifact 'corda-lib-dev:com/r3/corda/lib/accounts/accounts-contracts/1.0-RC04/accounts-contracts-1.0-RC04.jar' due to conflict in the snapshot release handling policy."
} ]
}
My build.gradle has
accounts_release_version = '1.0-RC04'
accounts_release_group = 'com.r3.corda.lib.accounts'
confidential_id_release_group = "com.r3.corda.lib.ci"
confidential_id_release_version = "1.0-RC03"
repositories {
maven { url 'http://ci-artifactory.corda.r3cev.com/artifactory/corda-lib-dev' }
maven { url 'http://ci-artifactory.corda.r3cev.com/artifactory/corda-lib' }
}
My local builds on my development environment work fine, I assume because I already have the jars in my .m2
Artifactory configuration has been changed to enforce separation between release and snapshot repositories. corda-lib-dev is a snapshot repo and CorDapp developers should not be developing against these.
Releases and release candidates will be available in corda-lib going forward.
Kindly use corda-lib, and develop again release 1.0.
The pom file with RC04 is set to return 409. I assume Corda's way to disallow use of RC04. May be RC03 is also the same. I just tried this today and saw the repository pom files.
Use "1.0" instead of "1.0-RC03"

Instalation of Intershop 7.9 failing on missing version for demo cartridges

I'm trying to install a demo shop of Intershop version 7.9 but i'm failing to get it working. When I run "gradlew deployServer" I'm getting an error on all dependencies of the first demo shop cartridge:
Could not resolve all dependencies for configuration ':app_sf_responsive:compile'.
Could not resolve com.intershop.business:ac_ecircle:.
Required by:
nl.test.testproject:app_sf_responsive:1.0.0-LOCAL
No version for module 'com.intershop.business:ac_ecircle' in project properties and no version declared in dependency. Consider adding a version or filter property to 'C:\projects\test7.9\projects\testproject\gradle.properties'
I have followed the complete Intershop manual Setup CI Infrastructure but there is one point I don't know exactly what to do, that's with the new versioning plugin.
It is in chapter 6.2.5, any one have an idea how to configure that?
After loads of tinkering and mails back and forth with Intershop support I found a solution.
My alterations are in section 7.2.4 of the Setup CI Infrastructure of Intershop:
https://support.intershop.com/kb/index.php/Display/279D85#Cookbook-SetupCIInfrastructure-CorporateArtifactsRecipe:SetupCIBuildforCorporateArtifacts
I Made sure the corporate distribution is unique since I have more that 1 Intershop installation. Otherwise the upload to Nexus(in my case) will still fail.
In the build.gradle of the corporate distibution folder added disableSCM = true in the scm.version section. It now looks like this:
scm {
version {
type = 'threeDigits'
increment = 'MAJOR'
patternDigits = 1
disableSCM = true
initialVersion = '2.0.0'
}
}
If this is not added I got a bad request httpstatus 400 from Nexus because it tried to upload it as a snapshot while the distribution repository is a release repository.
Another problem is the distributionURL in the project/gradle/wrapper/gradle-wrapper.properties
All Nexus repository URL's are build up with < repoBaseURL > + repositories/snapshots, but the distributionURL is missing the repositories part.
After applied those changes it worked for me.

How do I add a Nexus resolver after local repository, but before the default repositories?

We have an internal Nexus repository that we use to publish artifacts to and also to cache external dependencies (from Maven Central, Typesafe, etc.)
I want to add the repository as a resolver in my SBT build, under the following restrictions:
The settings need to be part of the build declaration (either .sbt or .scala, but not in the "global" sbt settings
If a dependency exists in the local repository, it should be taken from there. I don't want to have to access the network to get all the dependencies for every build.
If a dependency doesn't exist locally, sbt should first try to get it from the Nexus repository before trying the external repositories.
I saw several similar questions here, but didn't find any solution that does exactly this. Specifically, the code I currently have is:
externalResolvers ~= { rs => nexusResolver +: rs }
But when I show externalResolvers the Nexus repo appears before the local one.
So far, I've come up with the following solution:
externalResolvers ~= { rs =>
val grouped = rs.groupBy(_.isInstanceOf[FileRepository])
val fileRepos = grouped(true)
val remoteRepos = grouped(false)
fileRepos ++ (nexusResolver +: remoteRepos)
}
It works, but is kinda dirty... If anyone has a "cleaner" solution, I'd love to hear it.

Iron router: Error: Couldn't find a template named "/" or "". Are you sure you defined it?

I have trouble setting up a simple iron:router example: (docs, sample app)
meteor create testapp
cd testapp
home.html:
<template name="Home">
<h1>Welcome</h1>
home
</template>
router.js:
Router.route('/', function () {
this.render('Home'); // Also tried 'home'
});
Starting the server:
meteor
Then I get (client side):
Exception from Tracker recompute function: Error: Couldn't find a template named "/" or "". Are you sure you defined it?
at null._render (http://localhost:3000/packages/iron_dynamic-template.js?32038885cb1dad7957291ffebfffcb7f8cd57d20:239:17)
at doRender (http://localhost:3000/packages/blaze.js?88aac5d3c26b7576ac55bb3afc5324f465757709:1853:25)
...
What am I doing wrong ?
Note: I get the exact same error if I clone the example application (basic.html and basic.js).
meteor list
autopublish 1.0.1 Publish the entire database to all clients
insecure 1.0.1 Allow all database writes by default
iron:router 0.9.4 Routing specifically designed for Meteor
meteor-platform 1.1.2 Include a standard set of Meteor packages in your app
Also:
meteor --version
Meteor 0.9.4 <- Why all standard packages and meteor platform are > 1.0 and this is 0.9.4 ?
Currently, there are two versions of iron:router.
iron:router#0.9.4 is the one added by default when you type meteor add iron:router, this version is the latest in the "legacy" branch of iron:router that came up more than one year ago, it's the one that everyone is probably still using, although they should definitely update to...
iron:router#1.0.0-preX with X = 4 as of 20/10/2014, which is a complete rewrite of the package intended to be backward compatible, but introducing a new, nicer and polished API. This version will likely be set as default when meteor hits 1.0.0 later this year. The problem is that github page of iron:router shows this particular branch (1.0.0-pre4) along with examples that people believe are usable with 0.9.4.
This means that you are most likely using the wrong version of iron router, remove it with meteor remove iron:router and meteor add iron:router#1.0.0-pre4 instead.
Recommended reading to learn about the latest iron:router syntax :
http://eventedmind.github.io/iron-router/
Sometimes the guide is not completely up-to-date with the pre-release version, if you want to keep up with the latest stuff take a look at github issues.

How to stop xsbt from reloading webapp on resources change

We are using sbt with xsbt-web-plugin to develop our liftweb app. In our project build we have several subprojects and we use dependencies of a Project to share some stuff between all the subprojects.
object ProjectBuild extends Build {
//...
lazy val standalone = Project(
id = "standalone",
base = file("standalone"),
settings = Seq(...),
dependencies = Seq(core) // please notice this
)
lazy val core = Project(
id = "core",
base = file("core"),
settings = Seq(...)
}
// ...
}
To ease the development we use 'project standalone' '~;container:start; container:reload /' command automatically recompile changed files.
We decided to serve some common assets from shared core project as well. This works fine with lift. But what we faced when added our files to core/src/main/resources/toserve folder, is that any change to any javascript or css file causes application to restart jetty. This is annoying since such reload takes lots of resources.
So I started investigating on how to prevent this, even found someone mentioning watchSources sbt task that scans for changed files.
But adding this code as a watchSources modification (event that println prints all the files) does not prevent from reloading webapp each time I change assets located in core resources folder.
lazy val core = Project(
id = "core",
base = file("core"),
settings = Seq(
// ...
// here I added some tuning of watchSources
watchSources ~= { (ws: Seq[File]) => ws filterNot { path =>
println(path.getAbsolutePath)
path.getAbsolutePath.endsWith(".js")
} }
)
I also tried adding excludeFilter to unmanagedSorces, unmanagedResorces but with no luck.
I'm not an sbt expert and such modification of settings looks more like a magic for me (rather then a usual code). Also such tuning seem to be uncovered by documentation =(
Can anyone please help me to prevent sbt from reloading webapp on each asset file change?
Thanks a lot!
You're on the right track by using watchSources, but you'll also need to exclude the resources directory itself:
watchSources ~= { (ws: Seq[File]) =>
ws filterNot { path =>
path.getName.endsWith(".js") || path.getName == ("resources")
}
}
Can you switch from using "resources" folder to using "webapp" folder? That will also free you from restarts. Here's a demo project for Lift (that uses "webapp"):
https://github.com/lift/lift_26_sbt/
For example, the "basic" template:
https://github.com/lift/lift_26_sbt/tree/master/scala_211/lift_basic/src/main/webapp

Resources