So I am trying to learn Bazel by setting up a barebones spring project. Newest spring boot 5 uses JUnit5. Bazel only natively runs JUnit 4. I find this repo https://github.com/bazel-contrib/rules_jvm that has a drop in replacement for "java_test" it. I believe I set it up as the repo describes...
load("#bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "contrib_rules_jvm",
sha256 = "59af045d288ad3e2d9000b1cddb1135f889d798830f7106a4792cc95427bcd99",
strip_prefix = "rules_jvm-0.7.0",
url = "https://github.com/bazel-contrib/rules_jvm/archive/refs/tags/v0.7.0.zip",
)
# Fetches the contrib_rules_jvm dependencies.
# If you want to have a different version of some dependency,
# you should fetch it *before* calling this.
load("#contrib_rules_jvm//:repositories.bzl", "contrib_rules_jvm_deps")
contrib_rules_jvm_deps()
# Now ensure that the downloaded deps are properly configured
load("#contrib_rules_jvm//:setup.bzl", "contrib_rules_jvm_setup")
contrib_rules_jvm_setup()
Adding this to my WORKSPACE file. As the top of the README says, and the lease page specifies. But when I attempt to use the new rule `
java_junit5_test()
It say it is not defined. Is there some special thing you need to do to reload a WORKSPACE file? I am using intelliJ with the bazel plugin. I also have the "maven_install" stuff all setup and working in the WORKSPACE file and it's pulling those packages just fine.
Was missing
load("#contrib_rules_jvm//java:defs.bzl", "java_junit5_test")
in my BUILD file.
Related
I'm (almost) a beginner in plugin creation (I created one a long time ago) and I would like to create a plugin that works BOTH with IntelliJ and with Android Studio (this to start with, because later I would like it to work also for Webstorm, PyCharm...).
The principle of my plugin is to use the parsing provided by IntelliJ (for Java for the moment, later for Kotlin, PHP...) thanks to the PSI (I MUST use PSI!). I've spent days reading and testing information at https://plugins.jetbrains.com/docs/intellij , https://plugins.jetbrains.com/docs/intellij/android-studio.html (and so on) and online tutorials, but I still can't configure my project (even before coding it).
Can you help me?
Here are some information:
I created the plugin ('empty' plugin for now) from the github template presented the online documentation. No problem for that.
I use a JDK 11. I guess this is what I have to do now (unlike before when I had to use the IntelliJ JDK).
I want to code my plugin in Java (not in Kotlin). The template generated Kotlin code (MyBundle.kt, listeners, services...) but I don’t need these Kotlin files. What to write to replace this code in Java ?
I don't know Kotlin (or very very little) and I usually develop in Java with Android Studio and Gradlen and I want to keep the build.gradle.kst (better than build.gradle).
I must also use a personal .jar file (not a lib like JSON for instance) for my plugin to work. Do I only have to add this jar in the libraries of the 'project settings' or do I have to do something else?
Here is my current configuration (most interesting parts):
plugin.xml (with error)
<depends>com.intellij.modules.lang</depends>
<depends>com.intellij.modules.java-capable</depends> // correct ?
<depends>com.intellij.modules.androidstudio</depends> // error : cannot resolve plugin in dependencies
<depends>org.jetbrains.android</depends> // error : cannot resolve plugin in dependencies
build.gradle.kts (with questions)
plugins {
// Java support
id("java")
// Gradle IntelliJ Plugin
id("org.jetbrains.intellij") version "1.4.0"
// Gradle Changelog Plugin
id("org.jetbrains.changelog") version "1.3.1"
// Gradle Qodana Plugin
id("org.jetbrains.qodana") version "0.1.13"
}
...
configurations {
create("externalLibs")
}
dependencies {
// to integrate my personal jar file , correct ?
"externalLibs"(files("lib/myfile.jar"))
// to integrate an external API , correct ?
implementation("com.foo.api-java-sdk:1.0.2")
}
gradle.properties (with questions)
# See https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
# for insight into build numbers and IntelliJ Platform versions.
pluginSinceBuild = 211
pluginUntilBuild = 213.*
# IntelliJ Platform Properties -> https://github.com/JetBrains/gradle-intellij-plugin#intellij-platform-properties
platformType = IC
#platformVersion = 2021.1.3
platformVersion = 211.7628.21 // to be compatible between IJ and Android Studio, OK ?
# Plugin Dependencies -> https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html
# Example: platformPlugins = com.intellij.java, com.jetbrains.php:203.4449.22
platformPlugins = com.intellij.java, org.jetbrains.android // is it correct ????
# Java language level used to compile sources and to generate the files for - Java 11 is required since 2020.3
javaVersion = 11
# Gradle Releases -> https://github.com/gradle/gradle/releases
gradleVersion = 7.4
If someone could give me the right configuration for all these files, it would be fine because I am totally lost and hopeless :-(
Thank you.
I try to work with JMeter 3.2 source but it's not compiling, It was missing mainly Bouncy Castle jars I added jars but still getting an error:
SMIMEAssertion.java include constructor SMIMESignedParser(BcDigestCalculatorProvider, MimeMultipart) which doesn't exists in JMeter's lib, Code failing:
s = new SMIMESignedParser(new BcDigestCalculatorProvider(), multipart);
s = new SMIMESignedParser(new BcDigestCalculatorProvider(), msg);
I added different jars of Bouncy Castle as latest bcprov-jdk15on-158.jar to older versions bcmail-jdk14-1.46.jar or others as bcpkix-jdk15on-1.55 or bcmail-jdk15-140.jar but still failed to compile
Does anyone knows the correct jars to add?
JMeter uses "ant" to build.
Based on https://github.com/apache/jmeter it looks like they use Travis to build and test (probably on Github).
Based on
before_script:
- test "x$RUN_CHECKSTYLE" != 'x' || ant -Djava.awt.headless=true download_jars install
(https://github.com/apache/jmeter/blob/trunk/.travis.yml)
it appears that you should run
ant download_jars
to get the jars you need. Locate them and add them to your build path.
(And this stuff is exactly why projects are typically migrating to Maven)
Edited in by other user after I wrote it:
Full explanation for building is here:
http://jmeter.apache.org/building.html
A PR of migration to maven is available and should be merged after 3.3 release.
I want to load JMeter test plan to the newest version of JMeter 3.
The original version of test plan was written on 2.11.
I have added all needed plugins to lib folder:
Standard set
Extras Set
ExtrasLib
Add all needed project jars to lib folder.
Updated jmeter.properties file:
plugin_dependency_paths=../lib/ext/ts/libs
search_paths=../lib/ext/ts/samplers
Now when I open the project I see below picture:
And how it should look:
All samplers are missed.
Here is snippet from stack trace:
2016/06/04 00:51:12 INFO - jmeter.save.SaveService: Loading file: C:\Users\Nazar\Projects\IdeaProjects\fx-performance-tests\jmetertest\FXLoadTesting-rmi.jmx
2016/06/04 00:51:12 ERROR - jmeter.protocol.java.config.gui.JavaConfigGui: Error setting class:'com.fx.test.sampler.rmi.search.post.PostFreightSearchSampler' in JavaSampler Post Freight Search, check for a missing jar in your jmeter 'search_paths' and 'plugin_dependency_paths' properties
2016/06/04 00:51:13 ERROR - jmeter.protocol.java.config.gui.JavaConfigGui: Error setting class:'com.fx.test.sampler.rmi.search.post.PostVehicleSearchSampler' in JavaSampler Post Vehicle Search, check for a missing jar in your jmeter 'search_paths' and 'plugin_dependency_paths' properties
It works only at 2.11 version of JMeter. Not at 2.13 or 3.
Is it correct behaviour? Or I am missing something important for loading jmx file?
You need to add the JARs to JMeter CLASSPATH.
Then it will work - At least in my case.
You most probably did not copy to lib folder a jar that contains the class:
com.fx.test.sampler.rmi.search.post.PostFreightSearchSampler
I have an archetype that we use to create new projects. At the point of project creation (i.e. when someone executes mvn archetype:generate) I want to pin some of the dependencies to RELEASE version available at that time (I strongly oppose putting <version>RELEASE</version> in POM file).
Is there a way I can make archetype to resolve RELEASE version and pin that for some of the libraries.
Only way I solve this problem right now is by releasing new version of archetype every time some of the core libraries are released and then hard coding versions of those in the archetype-resources/pom.xml
I did see couple of similar questions but none of the solutions for those work for me.
As I already mentioned, that I want to pin the latest release version available at the time of creating project from archetype. Using `RELEASE means that I can not recreate binaries from same source code as I will end up fetching a different version of dependency.
Let me explain with concrete example.
I have an archetype with maven co-ordinate com.my-company:my-awesome-framework:1.0.
I have a library with maven co-ordinates com.my-company:core-lib:1.0.
Developer-1 runs command mvn archeype:generate my-awesome-framework. He fills in required details and creates project called service-foo. service -foo has dependency core-lib and since.
We add more features to core-lib and release version 2.0
Developer-1 build service-foo it still builds with core-lib version 1.0. (since he hasn't changed the version the project's POM file. Had I used <version>RELEASE<version> for 'core-lib, this timeservice-foowould have built with version2.0of thecore-lib`)
Devloper-2 runs mvn archetype:generate my-awesome-framework. He fills out required fields and creates a service called service-bar. Now this time since core-lib version 2.0. Note that I did not modify my-awesome-archetype to update version for core-lib inside archetype-resources\pom.xml
I hope this clarifies my use case
I solved this using archetype-post-generate.groovy, script. Maven archetype plugin executes that (if available) after the project has been created. There one can use Maven versions plugin to update to the latest releases.
Here is an example how you can update both versions in properties and in parent project (in Spring Boot in this case):
dir = new File(new File(request.outputDirectory), request.artifactId)
def run(String cmd) {
def process = cmd.execute(null, dir)
process.waitForProcessOutput((Appendable)System.out, System.err)
if (process.exitValue() != 0) {
throw new Exception("Command '$cmd' exited with code: ${process.exitValue()}")
}
}
run("echo 'Updating to latest Vaadin version...'")
run("mvn versions:update-properties")
run("echo 'Updating to latest Spring Boot version...'")
run("mvn versions:update-parent")
The downside is that Eclipse don't seem to execute that script, but in other major IDEs and command line this work just fine.
The groovy script form my Vaadin + Spring Boot archetype in GitHub.
How can I download dependency with sbt? With maven it is:
mvn dependency:get
Is there analog in sbt?
Unfortunately there is no single sbt command that can be used for this. However, sbt provides a dependencyResolution task key that can be used to implement a custom task to download a single jar from a repository.
Here is an example implementation (add this to the build.sbt):
lazy val downloadArtifact = taskKey[Unit]("Download an artifact")
downloadArtifact := {
val module = "com.typesafe.scala-logging" %% "scala-logging" % "3.9.2"
val dr = dependencyResolution.value
val files = dr.retrieve(
dr.wrapDependencyInModule(module exclude("*", "*")),
retrieveDirectory = new File("target"),
log = (streams in Compile).value.log
).fold(e => throw e.resolveException, identity(_))
println(files)
}
Caveats:
By default, recent sbt versions use coursier for dependency resolution, and coursier has a bug where it ignores the retrieveDirectory argument (see https://github.com/sbt/sbt/issues/5465). This means that downloaded files won't be placed into the retrieveDirectory even though the API assumes that. You can either disable coursier and use ivy instead (useCoursier := false), or copy the files yourself to the desired destination (the files value above is a List[java.io.File] with the downloaded files.
Notes:
DependencyResolution.retrieve downloads the artifact and all of its dependencies. This is why exclude("*", "*") is added above - to only download the artifact itself and exclude all of its dependencies.
Even if you retrieve a single dependency, with coursier this function may produce a list of multiple file locations (I assume that this is due to the specificities of the dependency resolution logic). You are OK to use any file from the list since, normally, all of them point to the same file.
Since this implementation uses the sbt's dependencyResolution, it respects any custom resolvers (custom repositories) that you may have declared in the sbt project.
Finally, although this isn't integrated with sbt, but maybe worh noting that if you happen to have coursier installed you can use coursier fetch:
cs fetch com.typesafe.scala-logging::scala-logging:3.9.2
Unless I misunderstand the documentation of mvn dependency:get, the equivalent in sbt is
> update
See Dependency Management Flow