How to programmatically retrieve some build files in TeamCity? - java

I'm currently doing a plugin for TeamCity 8.1.4 to support our tool. The latter generates some JSON and HTML/CSS/JS files I would like to include in TeamCity UI through respectively a graph and some kind of frame I guess.
Our tool is supposed to generate these files in the directory of the project after each build is finished. I read in the docs that I could create "build artifacts", which are basically files kept on the server side. I figured I could then access them with getArtifactsDirectory() method from SBuild interface. The thing is, I have no idea how to instruct TeamCity to create a build artifact programmatically. Or maybe I'm thinking this backwards and there's another way to do this... I'd appreciate some pointers since the Plugin community forum looks dead.

If you are looking to adding an HTML content to build results or projects, please check out this documentation page: 'Including third-party reports in build results'
Configuratoin described in this doc can be done using Java API:
see jetbrains.buildServer.web.reportTabs.ReportTabManager docs to configure tab settings on server side.
see jetbrains.buildServer.agent.artifacts.ArtifactsWatcher to publish files from build agent. This one is used to publish files as build artifacts.
UPD The abovementioned components can be used by plugin to configure 'third party report tab' (without any manual configuration). This way, plugin can provide html report from build without need to access uploaded artifacts.

Related

Neo4j: Which internal module responsible for verifying WHERE conditions from cypher?

My goal is to add to neo4j engine additional (global) filtering rules.
According to this answer:
Cypher is build on the Traversal API
Though I tried to set breakpoints in PathExpanders.scala and StandardExpander.scala and it seems they aren't triggered while executing cypher MATCH query.
Also modifying PathEvaluator in Evaluators.java didn't affected results for cypher queries.
I also inspected ast.rewriters which are triggered during cypher parsing, though it seems that I need to embed global filtering on later steps - when engine selects data from store.
Tried to understand internals from this diagram presentation: https://www.slideshare.net/thobe/an-overview-of-neo4j-internals
Though there is not much information about exact modules.
In which place verification of node/relationship properties happens for cypher queries?
Links to internal docs also would be helpful!
You are in the right place:
Cypher is build on the Traversal API
The problem seems your IDE is not hitting the breakpoints, if you are using eclipse the most sure-fire way to do this (and end up with something that's actually useful) is to download the source, and set up another "Java Project" pointing at that source.
To do that, get the source downloaded and unzipped somewhere on your system. Click "File"->"New"->"Java Project". In the next dialog, give it a project name and select "Create Project from Existing Source". Browse to the root location of the open source library.
Supposing that all the additional libraries that are required by the project and such are included in the project you downloaded, Eclipse will figure everything out and set the build path up for you.
You'll need to remove the open source jar from your project's build path, and add this new project to the build path of your project.
Now, you can just treat this as your code, and debug at will.

Is it possible to load an eclipse Java project using JDT in the headless mode?

I have an eclipse Java project and want to get information like project source dir, classpaths, etc. My current implementation parses the .project file. But as I didn't find any official documentation describing the structure of the .project file, I have some concerns for the robustness of this approach.
A more convenient and robust way would be to use JDT (headlessly) to load the project and get the relevant information from the IJavaProject object.
Although the developer guide of JDT says
JDT Core packages give you access to the Java model objects and headless Java IDE infrastructure.
all the examples I can find opening an existing Java project get the IJavaProject object from projects within a workspace or use an IProject object. But I couldn't find the way to add a project to the workspace or to construct a IProject/IJavaProject from a path to .project file.
Could anyone please help?
Yes, and can all be done through clear and stable API. org.eclipse.jdt.core is a plug-in, just like org.eclipse.core.resources (which is where you would get an IWorkspace instance), and they both expect to be running within an Eclipse runtime, which can be headless if that's how you write your Eclipse Application. JDT uses the .classpath file to record where sources, libraries, and build output are, and what abstracted references to libraries to use, while the .project file is what records what kind of project it is in general--Java, PHP, Web, some combination of those or others--and a little more information about what builders to execute.
So make yourself a headless Eclipse Application, or package your end-goal functionality inside of one.
https://wiki.eclipse.org/FAQ_What_is_an_Eclipse_application%3F
https://wiki.eclipse.org/FAQ_What_are_extensions_and_extension_points%3F
http://help.eclipse.org/mars/topic/org.eclipse.platform.doc.isv/reference/extension-points/org_eclipse_core_runtime_applications.html?cp=2_1_1_27
http://help.eclipse.org/mars/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/core/resources/ResourcesPlugin.html#getWorkspace--
http://help.eclipse.org/mars/topic/org.eclipse.jdt.doc.isv/reference/api/org/eclipse/jdt/core/JavaCore.html#getJavaCore--
http://help.eclipse.org/mars/topic/org.eclipse.jdt.doc.isv/reference/api/org/eclipse/jdt/core/IJavaProject.html#getResolvedClasspath-boolean-
See http://www.ant4eclipse.org/ for a project which allows you to work inside Eclipse projects.
I used it for a bit some years back, and found that this is too brittle for long term usage and build scripts. I would recommend against relying on internal Eclipse things. They break! Typically when mixing releases.
Instead I would suggest you move to Maven. This is a bit more work, but allows you to use the whole maven infrastructure and API's to do things. What you want to achieve here, may be possible already using a Maven plugin.

Add Copyright header to all project files (.java, .xml, ...)

I have several maven projects where I'd like to add a common header (copyright information, etc.). Is there a tool, or Eclipse plugin, to do this?
A simple shell script won't do the job, because some files already have such a header - and I don't just want to blindly append another header.
So some plugin with "sophisticated" logic would be appreciated ;-)
If your project supports Maven, you can use maven-license-plugin
There are instructions how to install and use it.

Using multiple projects in Eclipse with Play framework 2.1.x

I have an existing project in Eclipse (let's call it "NotPlayProj") which has a lot of java code still under development. I made a new eclipse project using play 2.1.0 (let's call it "PlayProj"). My goal is to use code from NotPlayProj in PlayProj and have both Eclipse and the Play compiler notice changes in either project.
If I go into the properties for PlayProj and add NotPlayProj via the Project tab, then method completion and inclusion works within eclipse, but the Play compile doesn't see the result. I've looked at Play modules and those don't seem to do what I want.
Is there any way to do this, ideally without modifying the NotPlayProj?
Edit ---
I've looked at http://www.playframework.com/documentation/2.0/SBTDependencies which shows how to export a jar from NotPlayProj into the PlayProj/lib directory, but this requires a manual export for each time NotPlayProject changes. I suspect that the Managed dependency section is supposed to cover this, but I've never used SBT before and am therefore probably missing something basic.
What you need is continuous integration.
Have a look at Jenkins: http://jenkins-ci.org/
You should setup a Continuous integration server and customize the builds you need.
Example:
You have your PlayProj running in some server, it needs to be able to use some of the latest classes from the other project called NoPlayProj.
Rebuild is a must, things such as downtime zero are difficult to achieve(At least I don't think this is what you are asking for either).
The steps you need to automate with Jenkins are:
1 - Build and deploy the latest version of NoPlayProj which is located in some repositorium
2 - Build and deploy the latest version of PlayProj which is located in some repositorium and also is contains your last commit where you updated the dependency that exist with NoPlayProj
A not very complex build and deployment instructions can be configured in Jenkins. This should speed you up a bit.
Also another suggestion would be to mavenize both projects if possible, this will help you manage the dependencies easier.
Just to clarify one thing, you said: My goal is to use code from NotPlayProj in PlayProj and have both Eclipse and the Play compiler notice changes in either project.
Well the order in which you execute the builds will be dependent in what you want to do as long as you update the dependency before you commit the code.
One last thing, if you don't want to deploy you don't have to do so you can create the Jenkins jobs, in such ways that you only build. With Jenkins you can do a lot of stuff, also you could execute some help scripts of your own that can provide you additional functionality.
I hope this was useful.
To let Eclipse see changes in NotPlayProj when working with PlayProj, it's enough to change configuration of PlayProj. Properties-> Java build path -> Projects -> Add NotPlayProj as dependency.
There is no straightforward way to let Play compiler handle dependencies, until you package it as jar. Consider configuration of simple ant task (External tools configuration -> Ant build ), which will copy your jar file. Task can be triggered by pressing the key or button.
With managed dependencies, every time you made change in NotPlayProj, you have to manually rebuild it. To let Ivy/Maven put dependency in your local repository. After that Play will take latest snapshot from your local repository.
Both approaches requires some efforts. Maybe you can take a look at Python scripts, which run Play, maybe it's enough to extend classpath with NotPlayProj when executing play start
Though I've never used the play framework, I would think that there is a format that both the play framework and eclipse understand and that is Maven. Look at http://www.playframework.com/modules/maven-head/home

Offline Javadoc Server

As not all our development machines have internet access, we want to cache the API docs of various libraries in our local network. I was thinking of a webapp that handles caching and listing the available Javadocs after someone uploads them (in jar format). Ideally, the source jars would be automatically pulled from our maven repository (artifactory).
I have not been successful in finding anything like this on google, so I'm trying my luck here.
EDIT
I have found a site that does exactly what I am looking for: http://www.jarvana.com The problem is that this site does not fulfill my #1 requirement - offline availability. So I rephrase my question to: Is there a webapp that works like jarvana but that can be deployed to a local server?
It seems like what I'm looking for really doesn't exist, so I've rolled my own really simple webapp that serves JavaDocs from a local maven repository (transparently extracting jar files). It's far from perfect, but it works for my requirements. If anyone is interested, I shared it on github:
https://github.com/planbnet/JavaDoc-Browser
Why not just use mvn site?
Hm, I'd better add something more useful than that :-)
mvn site will build and deploy a bunch of site reports including the javadoc (assuming you configure that plugin). Everytime your CI server builds the code from trunk/branch/tag/whereever, the latest Javadocs will be generated and stored on the file system (accessible via HTTP)!
There's even a cool report that ties the javadoc into the source code.
You can give wwwoffle a try. A caching proxy which enables to access sites while you're offline.
I wrote a python script some time ago to serve the javadoc from my local maven repo:
http://blog.robotninjas.org/2013/04/17/accessing-your-cached-javadoc-offline/
python javadoc.py
It's crude, but hitting http://localhost:8080/m2 will list all of the projects in your local maven repository with downloaded docs.
You can download all the javadoc jars for a maven project with:
mvn dependency:resolve -Dclassifier=javadoc

Categories

Resources