Build KafkaOffsetMonitor tool manually - apache-kafka

I am trying to monitor kafka using KafkaOffsetMonitor tool. It is working fine as I used already built jar available at its github page. Now I want to make some changes in this tool but I dont know how to manually build it. I have downloaded the zip file from github page. Now how should I build it?
PS: Steps would be helpful

Below are the steps which may help you:
1. Checkout and get the source code into your local machine or you may have to unzip it if you have downloaded zip file.
2. Go to the folder which you have extracted or checked-out.
3. Run below command:
mvn clean package -U -DskipTests
Note: make sure you have installed maven in your machine.
Make the changes in the source if you want to modify the tool and build it using above steps.

I know that I'm coming at this pretty late, but I ran into the same problem. Basically, you need a Java jdk, scala, and sbt installed first. You didn't post what os you're dealing with, so it would be hard for me to give you steps for that. I use Gentoo Linux and you can install it by running emerge -av sbt
Once sbt is installed, just clone KafkaOffsetMonitor Github repository change to the top level directory and run the following sbt command: sbt assembly
The jar you will be looking for will be in: ./target/scala-<scala_version>/KafkaOffsetMonitor-assembly-<kafkaoffsetmonitor_version>.jar

Related

Is there a way to build Scala 2.10.3 from source code?

I know it's a very old thing now, but I need it.
I download scala-sources from the link, unpacking on Ubuntu 20.04. Also I download Ant 1.7.0 and install it. Also I download Apache maven 2.2.1 (or I tried maven 3.5.0) and install it.I also use jdk1.8.0.
I am trying to run "ant" or "ant build" from the scala directory, and something happens, but the build failed for the following reasons:
failed to create task or type scalacfork
Build failed
The following messages also appear at the top:
[taskdef] java.util.zip.ZipException: zip file is empty
(several times)
...
[WARNING] POM for 'biz.aQute:bndlib:pom:1.43.0:compile' is invalid.
...
[taskdef] Could not load definitions from resource scala/tools/ant/sabbus/antlib.xml. It could not be found.
I understand that many things are no longer available now and are definitely not supported, but maybe someone will tell me a way to get the result.
Maybe I can download the necessary data and manually build scala? I'm new to this and don't quite understand what and where I can change. And I can't use a newer version of scala because of work.
I hope for any help. Thank you in advance.
Yes, it is possible. Although it requires some patches in the build process and a few workarounds.
Read the README.rst, it contains some information on how builds are structured
Run git init, git add ., git commit as the build uses some git info (commit hash, etc) during build. It may be not needed for release, but I have not tried.
You need either JDK 1.6 or JDK 1.7. It can't be built on the 1.8 JDK (compilation fails if you remove checks from build.xml). And on 1.7 it says it can't build swing library so you won't be able to build distribution.
Fix the tools/binary-repo-lib.sh and change URLs to https otherwise fetching artifacts will fail. Maybe you have to remove some of the curl arguments to see what happens, maybe it won't be required.
Run pull-binary-libs.sh
Fix build.xml to use https protocol. This is based on the Official usage documentation. You have to define repository before the first artifact:dependencies task in the file (I did that in the same block).
<artifact:remoteRepository id="central" url="https://repo1.maven.org/maven2" />
Then you have to tell every artifact:dependency task to use that repo by adding the remoteRepository element, the tasks should look like
<artifact:dependencies pathId="extra.tasks.classpath" filesetId="extra.tasks.fileset">
<dependency groupId="biz.aQute" artifactId="bnd" version="1.50.0"/>
<remoteRepository refid="central"/>
</artifact:dependencies>
I think this was enough for me to build it using ant build on JDK 1.7 (apparently, swing libs were not built).
But probably the easier way would be to just download prebuild Scala version or tell your build tool to use the Scala version you want.

SBT always downloads the packages/scala libraries on Docker, docker-compose

I have recently installed SBT on Docker Ubuntu machine to get started with Scala. When I started docker initially, it started grabbing all the Java, sbt JAR's from the remote locations (https://repo.scala-sbt.org/scalasbt/debian/sbt-0.13.17.deb).
But, whenever I run sbt command, it again starts downloading the sbt JAR. Is there a way of maintaining a global cache whereby artifacts are only downloaded once and not every time I remote to docker container?
My solution to this was a multi stage build.
Have a “base” docker image.
Copy in only build.sbt, projects.sbt and the file which sets out the sbt version from your project.
That defines the required dependencies. The last line in that base image is “sbt update” - I.e fetch them. That “base image” has the dependencies in it… and is reuseable. Just remember to run it when you change library versions etc to rebuild it.
In the ”build” image… copy over the project and proceed as normal… make sure sbt is resolving from maven-local, and it should use the “cache”… which is already in place from the paragraph above.
I’d be interested to hear other answers, but that’s my solution… YMMV :-).
That works for me on a cloud / Kube pipeline.

creating geoserver war by modifying source code

I am trying to build geoserver from source code with some changes.
I had installed the following for build and add to path in environmental variable:
"C:\apache-maven-3.5.0\bin; C:\Program Files\Java\jdk1.8.0_111\bin ;C:\Users\Administrator\eclipse\java-neon2\eclipse\eclipse.exe"
At command prompt to the path "C:\geoserver_build\src"(source code), I had run the following command and build successfully:
"C:\geoserver_build\src>mvn -DskipTests clean install -P allExtensions"
"C:\geoserver_build\src>mvn -DdownloadSources eclipse:eclipse"
After this I import the project in Eclipse and run the Maven build.
I navigate to gs-web-app > src/test/java/org.geoserver.web > Start.Java, after succesfull run as Java application start I am able to run http://localhost:8080/geoserver/web/ and its working fine.
I had made some change in geoserver and change an png with modification located at "C:\geoserver_build\src\web\core\src\main\java\org\geoserver\web\img".
Now I want to make geoserver.war file with change I had made.
I had gone through "Geoserver generate web archive file", but not helped out.
Please suggest me the way to do in detail.
The developers' guide does include instructions on how to build GeoServer using maven.
It should be as simple as:
mvn clean install -P allExtensions

Installing Jenkins plugin (mercurial) in Docker shows in plugins folder but not in Jenkins itself

Problem: I can't seem to successfully install the mercurial plugin to jenkins using the Dockerfile and plugins.txt combination.
What I've done so far:
I have a Dockerfile that's loading Jenkins. It has the following lines:
FROM jenkins:1.642.1
COPY plugins.txt /usr/share/jenkins/plugins.txt
RUN /usr/local/bin/plugins.sh /usr/share/jenkins/plugins.txt
My plugins.txt has this line:
mercurial:1.54
When I build the image and run the container, everything seems to work, there are no errors or complaints. But the Mercurial plugin isn't marked as installed when I go to Manage Plugins, and if I try to make a build, Mercurial isn't an option under Source Code Management.
I've tried going to:
<jenkins ip address>:8080/reload
As well as the "Reload Configuration from Disk" option in Manage Jenkins. Mercurial still isn't visibly installed after either of these.
I've also done this on the command line:
docker exec -i -t container bash
ls /var/jenkins_home/plugins/
And at this point I'm totally confused, because there's mercurial, mercurial.jpi and mercurial.jpi.pinned right there in the list. Does anyone have any ideas on this? I would like to have Mercurial installed on Jenkins as soon as it's loaded from the Dockerfile without having to do it manually...
Also, I tried doing this with git-changelog as well to see if another plugin would work better, and had the same result.
As you can see on the Mercurial Plugin wiki page, the plugin currently has four mandatory dependencies, and one optional:
credentials
matrix-project
multiple-scms (optional)
ssh-credentials
scm-api
The plugin installation mechanism that you're using with the Jenkins Docker image does not automatically install dependent plugins for you, as mentioned in the documentation for the jenkins image:
All plugins need to be listed as there is no transitive dependency resolution.
Therefore you need to additionally list those plugins, and any of their transitive dependencies, in your plugins.txt file.
At the moment, the simplest way to get the full list would be to start your container (potentially without plugins.txt), and then install the Mercurial plugin via the Plugin Manager, which will be installed along with all of its dependencies. Then you can see a list of which plugins are required via $JENKINS_HOME/plugins.

scala and akka on linux: compiling and executing

I'm trying to run a scala/akka based program on a linux cluster machine. I was following the tutorial link (this was the only example I could find):
http://doc.akka.io/docs/akka/2.0/intro/getting-started-first-scala.html
It says to use the command to obtain the akka library:
git clone git://github.com/akka/akka.git
But it doesn't have any jars files inside it as per the tutorial.
I'm not able to get a basic akka-scala-sbt combo working on linux. So any help on this is much appreciated. I'm not aware (not able to find any clear source) of the commands needed to compile/execute with and without using SBT.
Java version: "1.8.0_31"
Scala version: "2.11.5"
Akka: I'm not sure, I did git clone, believe its the latest
SBT: 0.13.9
Java,Scala are already installed on the cluster, I had to just use module load.
You can start with this simple example: https://github.com/izmailoff/SmallAkkaProjectExample. It will help you to understand how to compile and run a project.
Usually the steps are:
Start SBT
Compile code
Run it from SBT
or:
Start SBT
Compile executable JAR
Run the JAR from command line
If you want a more advanced example take a look at: https://github.com/izmailoff/remote-akka-server-template
In either of these projects you don't need to download any libraries/JARs. SBT will download everything you need automatically.
In short, you need to understand how to build projects with SBT and how to run them - not related to Akka. Separately from that you need to know how Akka runs, i.e. ActorSystem, kernel, etc.