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

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.

Related

Download a feature using Maven

To integrate JavaFX into an existing RCP client I need to add the fx.runtime and fx.target features of the e(fx)clipse project to my IDE. I know that the usual way would be to download these by going to the targetplatform -> add new software, however I'd like to download these features and add them to a virtual P2 repository.
Is it possible to download a feature structure like in http://download.eclipse.org/efxclipse/runtime-released/2.3.0/site/ with Maven in a single pom.xml?
This is what I was looking for:
eclipse -nosplash -verbose
-application org.eclipse.equinox.p2.metadata.repository.mirrorApplication
-source Insert Source URL (e.g. http://download.eclipse.org/eclipse/updates/3.4milestones/)
-destination Insert Destination URL (e.g. file:/tmp/3.4milestonesMirror/)
More on this topic
Search for it here : https://mvnrepository.com/.
Copy despondency and you are ready to go.

How to programmatically retrieve some build files in TeamCity?

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.

Is it possible to modify eclipse workspace via command-line?

Is it possible to access/manipulate an eclipse workspace via command-line?
I'm primarily asking about the workspace metadata rather than the files itself.
E.g. do things like
modify resource attributes (e.g. settings some resources to derived)
import existing projects
access markers
There are no command-line (headless) tools that I know of to perform these types of tasks. There are a few scripting projects for Eclipse out there that would provide a light-weight, scriptable interface to using the Eclipse API, however, none of them have command line available, I believe all of those scripting tools are UI based.
Another option would be to use Eclipse SDK to build an Eclipse application (headless app) that uses the Eclipse application model to perform the commands you wanted, but you would have to write the code yourself.
Here is a list of eclipse command line options: http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fmisc%2Fruntime-options.html
Doesn't seem like there's one allowing to set the workspace, though...
Eclipse is not designed to be used on the command line. If you want to work with the command line I would highly recommend to use a build manager like Apache Maven or Apache Ivy in your project. The advantage is that your build does not depend on Eclipse, you can switch the IDE if you want and you can build your projects and edit dependencies on the command line. Your project and its build/deployment should be independent of an specific IDE.

How to wadl2java these days?

I have real difficulty finding commandline tool to convert WADL to java. No matter how much I try to google, follow blogs or java.net doc, there is no real download link. (links are broken or obsolete).
What particular vendor, community group is supplying this tool ? Does free download link exist ?
The generated code should be able to reconstruct POJOs from XML responses and survive inside Tomcat 7.
Thank you
Answer: (this works only after June 2011):
Take Apache-CXF-2.4.1.zip (not any of the earlier versions)
Extract it to root folder
Take Apache-CXF-2.4.1.src.zip
Search for folder named distribution inside src
Extract ditribution folder and merge it with no overwrites to root folder
goto bin and spot the wadl2java.bat
run wadl2java.bat from command prompt
continue with no brainer details
Apache CXF recently added support for WADL-first development of REST services. For more background information on its wadl2java tool, this blog entry by one of the CXF committers should help.
I had some trouble using the CXF 2.5.4 wadl2java tool. It kept complaining of a missing "resources" element in my WADL file, even though it contained one.
wadl.java.net has a download of wadl2java that worked for me.
Just to give an update with CXF version 3.2.1 it worked for me.
Steps are
Download anywhere
Unzip
Go to /bin
Run wadl2java to get the usage
Run wadl2java -p com.x.y.z wadl-file.xml to generate your classes in current directory.
By the way I noticed that it created a class with a space in the name and also created classes with name starting with digits :)
As of Apache CXF version 2.7.11 just download the binary zip / tar.gz, set CXF_HOME env-var to /path/to/apache-cxf-x.y.z and wadl2java is available at $CXF_HOME/bin
For generating client side stubs from WADL, use a tool wadl2java.
Download wadl tool from here:-
http://search.maven.org/remotecontent?filepath=org/jvnet/ws/wadl/wadl-dist/1.1.5/wadl-dist-1.1.5-bin.zip.
For genearting client side java stubs(POJOs), use this command:
\wadl2java -o .\src -p com.test.client WADL_FILE_LOCATION
If you are using maven project then you can use wadl2java maven plugin for this work.

Tool for creating Dynamically Generated Code in Java (In Eclipse)

In Visual Studio land, I used to be able to define a structure in an XSD file and add a special attribute to it which would cause it to be dynamically compiled and available to use with intellisense in the other C# files in the application. I am not sure exactly what the term for this is, perhaps "dynamic code generation."
I am trying to accomplish the same in Java using Eclipse IDE. Basically what I am looking for is a tool that will allow me to specify some template and generate Java code from it in a "hot folder" that will allow me code complete in the other static Java files.
Does anyone know of a solution for this? I know it is possible in Visual Studio, but I can't seem to find anything for Eclipse.
Ok, here is exactly what I want to do.
Step 1. I create a folder called templates
Step 2. I create a file called HelloWord.ibes
Step 3. Code it automatically generated in my src folder HelloWorld.java
I want to be able to do this in eclipse easily.
You may create an ant build file that does the source generation for you. Then you are free to use any code generator you like. Ant support is part of the eclipse IDE. If you prefer maven, there's a nice eclipse pluging available (that's what I actually use for source code generation based on jaxb, javacc and xdoclet...).
Technically spoken, you just add another eclipse builder which is invoked anytime eclipse detects a change in your code base.
If you already have a code generator in mind, just 'ask' the internet if there's a plugin available.
Edit
On how to install a builder: This is done automatically. For maven, you just install the maven plugin (m2eclipse) and enable maven dependencies for a project. Then if you look at the projects properties pages (Builder section), you find a second entry in the list of builders.
It's similiar with ant, even easier, because ant is already integrated. "enable" ant for a project and the builder is added to the list of builders for the project. You can deselect it at any time if it kills performance or switch of automatic building (I don't know by heart how to enable ant builds for a project, but I remember that the eclipse help had sufficiant informations).
All about ant can be found here: Apache Ant
Creating a new builder is difficult, as it has to be coded in java and added to eclipse as a plugin. I bet you don't want to follow that track ;)
I'm not sure whether you have seen the code template option?
Preferences.Java, Code Style then Code Templates
How
to add code templates
Useful
code templates

Categories

Resources