I've had a legacy eclipse e4 application product dropped in my lap. Plugin-based, circa 2014.
Right now the build process is "Run eclipse, then do these point-n-click things". It needs the build & product-export processes automated. That is, made invoke-able from a command line.
Build automation was trivial. The Eclipse-created ant scripts work fine.
Product-export automation is proving quite annoying.
So far I see four options:
Invoke eclipse's Product Export Wizard from the command line.
Identifying the wizard specifics was easy (via the Plugin Selection Spy).
But there seems to be no way to make eclipse run a wizard from the command line.
Convert the existing plugin project to Maven/Tycho.
Theoretically modern and nice, but the details are messy.
Configure | Convert to Maven Project runs with no errors, but the resulting maven configuration is badly broken.
The project also has numerous out-of-date dependencies with no standard maven repo.
So a conversion to maven is far from straightforward.
Completely reorganize under a new maven/tycho project, just bringing over source files, icons, etc.
This still has the dependency issues, plus whatever unknowns crop up.
It would also trigger an in-depth QA cycle. I'd rather avoid that.
Create a second e4 application that (using EASE) runs the product-export wizard on the existing project.
IMO this is a blatant hack. I hate this idea, even though it would probably work.
Note: This is eclipse 4.15 on Windows. The installation is very fragile. It cannot be easily updated, because some of the code depends on the out-of-date dependencies.
I'd really prefer #1. Its non-invasive and bypasses a whole raft of issues.
But I'm stuck on the wizard-from-command-line.
Anyone done this particular type of eclipse automation?
Related
I am new to J2EE. I would like to create a Spring+Primefaces+Hibernate project.
I googled for it.
But I found all projects examples show in internet contains maven. My questions are
Is it possible to create a spring+primefaces+hibernate project in eclipse without Maven? If no, what is need of maven?
How to add the jar file of primefaces and spring and hibernate in eclipse?
Will the spring controller xml file (spring context or dispatcher servlet) be created automatically or manually?I mean Spring MVC.
Will the hibernate file (mapping file) also be created automatically or manually?
If possible, can anyone guide me to tutorial (preferably video) to implement the same?
I am using tomcat 7 and Eclipse - kepler.
Any help is appreciated.
If this is downvoted , do specify the reason also.
Although it's not a 'must' to use Maven or any other build tool, you should strongly consider using one.Eclipse Kepler has by default maven support but feel free to use other build tools(Gradle, Ant) or none(see 2.).Maven and the other build tools remove the headache of scaffolding, searching for dependencies(external jars like spring-mvc, hibernate, some db drivers), even deploying applications in a server.
If you chose not to use a build tool you have to manually get your project dependencies and enter them
into your project's buildpath(Right Click -> Build Path then enter their location).As you have noticed this step can be really really time consuming...
No, you have to manually create the configuration unless you use another project that already has what you need, again this might get easier with a build tool(maven archetypes for example)
The same as 3.
You won't have a hard time finding resources about these technologies, they are being used practically everywhere, and I think the Spring team has some videos in their YouTube channel.
Hope that helps a little!
1:* The fundamental difference between Maven and Ant is that Maven's design regards all projects as having a certain structure and a set of supported task work-flows (e.g., getting resources from source control, compiling the project, unit testing, etc.). While most software projects in effect support these operations and actually do have a well-defined structure, Maven requires that this structure and the operation implementation details be defined in the POM file. Thus, Maven relies on a convention on how to define projects and on the list of work-flows that are generally supported in all projects.
This design constraint resembles the way that an IDE handles a project, and it provides many benefits, such as a succinct project definition, and the possibility of automatic integration of a Maven project with other development tools such as IDEs, build servers, etc.
But one drawback to this approach is that Maven requires a user to first understand what a project is from the Maven point of view, and how Maven works with projects, because what happens when one executes a phase in Maven is not immediately obvious just from examining the Maven project file. In many cases, this required structure is also a significant hurdle in migrating a mature project to Maven, because it is usually hard to adapt from other approaches.
In Ant, projects do not really exist from the tool's technical perspective. Ant works with XML build scripts defined in one or more files. It processes targets from these files and each target executes tasks. Each task performs a technical operation such as running a compiler or copying files around. Targets are executed primarily in the order given by their defined dependency on other targets. Thus, Ant is a tool that chains together targets and executes them based on inter-dependencies and other Boolean conditions.
The benefits provided by Ant are also numerous. It has an XML language optimized for clearer definition of what each task does and on what it depends. Also, all the information about what will be executed by an Ant target can be found in the Ant script.
A developer not familiar with Ant would normally be able to determine what a simple Ant script does just by examining the script. This is not usually true for Maven.
However, even an experienced developer who is new to a project using Ant cannot infer what the higher level structure of an Ant script is and what it does without examining the script in detail. Depending on the script's complexity, this can quickly become a daunting challenge. With Maven, a developer who previously worked with other Maven projects can quickly examine the structure of a never-before-seen Maven project and execute the standard Maven work-flows against it while already knowing what to expect as an outcome.
It is possible to use Ant scripts that are defined and behave in a uniform manner for all projects in a working group or an organization. However, when the number and complexity of projects rises, it is also very easy to stray from the initially desired uniformity. With Maven this is less of a problem because the tool always imposes a certain way of doing thi
2:* You have to download all required jars file for hibernate/spring/primefaces from internet and place them in your project build path or in lib folder.
3:* Spring configuration files need to be created by you so that you can get the concept.
4:* Hibernate mapping files can be created by using reverse Engineering techniques for hibernate from where you can generates hbm files or you can use annotations if you dont want xml.
I suggest you to first create a sample java project in eclipse then download all required jars and place them in lib folder. Then configure hibernate in projects and spring integration.
I use Java/Eclipse for development and I've never really used any conventional build tools like ant or maven. I generally just rely on building projects through eclipse and I rarely use commandline. I don't really want to spend time getting to know ant/maven, but I'd like to know whether eclipse can really substitute all functionality of ant/maven through its .classpath file any other settings.
(Please don't suggest me some tutorial that makes it really easy to learn ant).
Eclipse knows how to build a project based on the .project and .classpath files.
build.xml is the default filename of build rules used by Ant, so that when you run ant without parameters, it will use this file to figure out what to do.
pom.xml is the default filename to describe a Maven project, so that when you run mvn compile, it will use this file to figure out how to build the project.
Eclipse can import a project based on an Ant build file or a POM file, and create the appropriate .project and .classpath files.
Eclipse, Ant, Maven are all different tools that cannot replace each other. They have some overlapping functions, but also some unique functions.
Being able to build a project using the command line is a very useful skill, and part of being a good programmer. In the Programmer Competency Matrix, being able to build your software using the command line is considered Level 1 (out of Level 0, 1, 2, 3), if you cannot do this, that's not so good.
http://www.indiangeek.net/programmer-competency-matrix/
I strongly recommend to learn Maven.
If your applications have little existence outside of Eclipse then maybe you should keep using Eclipse in that way. But Eclipse is a developer tool (developer as in the person who writes the code). Any other than the most trivial projects have to deal with roles other than developers. and applications go through an entire life cycle. In fact, different axes of life cycles exist, whether it being from a project management perspective, from the perspective of deliverables traversing a number of phases such as coding, compiling, assembling dependencies, packaging, deployment, or from other perspectives.
When you look at those deliverables traversing phases, a lot of these steps can be done (manually) from within Eclipse. So, again, if that works for you, praise. However, it misses automation and for some steps (phases) Eclipse just ain't the right tool. For example: Continuous Integration is not something Eclipse is built for. A CI server may want to checkout your sources and build stuff from scratch. It needs to find dependencies and such, may do so on basis of Eclipse's .classpath file, but that introduces a dependency on Eclipse. Now, I've seen large companies do it exactly that way, but it's a bit clunky because that's again not what Eclipse was meant for.
Instead there's tools that are great at dealing with the entire* life cycle.
*Note that "entire" is a very subjective matter. From a developer's perspective the life cycle may be nicely split up in phases, but other people in your larger organization may find that their duties are underrepresented in any given breakdown of life cycle phases.
Maven or Gradle are such tools. Look at them as an assembly line with a number of stations. The developer is at one of the stations, using Eclipse, but underneath the assembly line keeps rolling. CI is another station, using Bamboo, Hudson, Jenkins or similar, but underneath still the assembly line at work. Within Eclipse the m2e plugin is the connector between Eclipse and the assembly line Maven.
A different approach to the matter is to use scripts, either to replace the manual steps that you're doing in Eclipse, to hook them together, or to complement them. There is clearly many languages that can be used, but within the build tooling domain Ant is wildly popular because its functionality aligns well with exactly this purpose.
If you're a professional software factory (which might already be the case for a single developer project) you need an assembly line. Maven or Gradle give you one out of the box. If you want to swim upstream you build your own, using Ant or other stuff. And if you really have no requirements in this area to speak of, keep doing things manually in Eclipse.
Even though being defined in XML, Ant comes naturally to us as developers, since it has much of traditional sequential programming languages. Maven and Gradle have a different approach, and have thus a steeper learning curve. But it is definitely worth it. If you do it their way things become a breeze and you don't have to code every other thing you want to add to your assembly line. This hand-crafted scripts always start small, but they never stay that way, do they? :)
In addition to all this, I'd like to mention that Maven is also really good at resolving dependencies. That's what it's most known for, but that's not what this question was about, and it is in fact only such a small part of what it can do for you.
Not long before I had digged into Ant and use it doing simple practice(compile,unit test,package).Now my usual work is under Eclipse for java development,the usual work can all be simply done through Eclipse' function:in-time compiling、click button to deploy、various wizard..
So I am wondering under Eclipse do we have a need for Ant.
And if it is, at which aspect should we use Ant along with Eclipse.
Building applications is not about just building them in your IDE. You need to setup an automated build and deploy method that can be run for, say, continuous integration and deployment. The built package has to be deloyed to various environments and finally production. You cannot build them out of your own box. You cannot build it out of your IDE. You need separate build system. That is where build tools like ANT come in.
Also note that the capabilities of IDEs for doing build, deploy is limited and that is not their strength. It is, however, possible to make use of ANT and its build scripts and run them out of eclipse. This way, you have a single set of scripts for both your local ( developer ) build and the main build process. With ANT being JAVA based, you can also suit your build tool to your needs by writing custom tasks etc.
Also, when you make use of something as standard as ANT for your build system, you can move to a different IDE like Intellij IDEA and still make use of the build system that you know.
Do you need Ant if you can build through the IDE? Of course not! You can see that yourself.
Should you still have a IDE independent build with standard tools? Of course!
Note I didn't say Ant. There are a number of build tools such as Maven or Gradle that are made to build Java programs. However, there are reasons why you want an IDE independent build system:
You have a Continuous Integration Server: You do have one. Right? If you don't get one. A Continuous Integration Server automatically builds your project (and runs every test) each time a change is committed to the version control system. It catches mistakes. It also provides an OFFICIAL BUILD. No more It worked on my machine! excuses. If the Continuous Integration Server can't build it and successfully run the tests, the software isn't good.
You have others who need to work with your project on a different computer in a different environment: The problem with IDEs is that its specific to your system. Someone else checks out your project, and they may be using a different IDE. They maybe have a slightly different setup. An independent build scripting language like Ant guarantees that they can rebuild your project as intended.
If you share a project with someone else, you need an independent standard method way of being able to build that project and to know exactly what is required for that build to work. IDEs can hide that information.
I am a benchmark tester using Ant everyday. Our environment has 7 test machines and 1 console machine. For each test run, the ant script updates the working copy, restarts the database, build the product and the Grinder with proper properties and deploy them to the machines, and starts them and the monitoring softwares. With the 1000-line-buildfile, I can just type in an "ant A B C D E"-like line in the terminal on the console machine. I don't think it's a good idea to do this in a IDE like eclipse or NetBeans or anything else.
Also, in my company's product, ant is widely used. We use ant to build sample data for the benchmark test; we use ant to update Tomcat which is going to be bundled with our product; we also use ant to build and run selenium tests.
What's more, when you want to release the source code, including the IDE project files is not a good idea because there are a lot of IDEs. And what if the user just want to get a fresh build from your latest code (if you don't provide nightly build)? Providing a set of ant (or other build tool) buildfiles is a good idea. With this, you can manage your classpath for the build.
The shortest answer here wold be flexibility. The IDEs may came with pre-defined functionalities and may even allow you to choose some options using wizards. It is like generating html with Dreamweaver or such tools. It will never be as flexible as the pure thing. For example NetBeans uses Ant underneath.
Quoted from: Netbeans: Build Tools
The default NetBeans IDE project system is built directly on top of
the Ant build system. All of the project commands, such as "Build
Project" and "Run File in Debugger", call targets in the project's Ant
script. You can therefore build and run your project outside the IDE
exactly as it is built and run inside the IDE.
Even after you use tools for that purpose you are most likely still to brush up. So, what I am saying is, what the IDEs do for you is only a subset of what you can do with the pure ant or maven( if you use it). For simple tasks such as compile and run, IDEs do pretty much a good job! But if you have a use case as complex as deploying on CI IDEs won't help you. You need the whole flexibility of your build tools.
Item 2 of the Joel Test is "Can you make a build in one step", but what is the best (or commonly accepted) way to achieve this? What are the pros and cons of using the IDE's command-line interface to do a headless build, as opposed to maintaining a build script that is completely independent of the IDE (e.g. using Ant or Maven in the case of a Java project).
I ask this question because I am experimenting with Maven, and was a bit surprised to find that even when using the m2eclipse plugin it's not really feasible to turn off Eclipse's Java Builder and delegate the whole build process to Maven while working on the project. It seems that if I want to migrate the project to Maven, I'll end up having to maintain two equivalent but different build processes, for example the command-line build will use the DataNucleus Maven plugin for enhancing JDO classes, while the IDE build will use the DataNuclues plugin for Eclipse; the command-line build will use the Tomcat Maven plugin, while the IDE will use Eclipse's web tools platform. This redundancy seems unfortunate.
I gather that NetBeans uses Ant for its build, which sounds like it would solve this problem. But unfortunately I'm using neither NetBeans nor Ant!
EDITED TO ADD: I found that I can set up a Maven builder in Eclipse with specific goals that call some of the Maven plugins that I'm using (e.g. in my case the goals "datanucleus:enhance process-resources" take care of JDO enhancement, resource copying, and native2ascii conversion). This leaves java compilation up to Eclipse, but still achieves some degree of integration with Maven.
The eclipse builder gives you intermediate and repeated building, but the "Joel Test" is really about being able to go from source to ready-to-deploy something in a single step. If you're using Maven, there's several ways of going about it - including just invoking Maven as a command line script from within Eclipse.
mvn package
Is what I most frequently used for a quick run through the whole build setup. You can extend Maven through the POM and inject some additional mechanisms if you want to. If you get a little more complex, it's often most effective to start using multi-module POM and maven setups to get functional tests integrated and running with the rest of the code.
Basically, let eclipse "do it's thing" with it's builders and take advantage of what it provides, but when you're ready to use the end product have it invoked from the command line through a continuous integration server (Hudson is a nice easy one to get and set up - free too: http://hudson-ci.org/). Presumably if you're looking at using Maven, you'll also have an instance of Archiva or Nexus set up as your DSL for the resulting libraries. You can have hudson invoke "mvn deploy" for regular checkin builds, or "mvn release:prepare && mvn release:perform" for when you're ready to cut the release (separate builds in Hudson work best for this)
You can do a headless build in an IDE. In eclipse you can execute an arbitrary shell command as an "External Tool". This is also true in IDEA and netbeans with a little effort. At the very least, this is a convenient test of the headless build that you should run whenever you make changes to the build configuration.
Also, I'd like to add that the build should be one-step as a minimum requirement. It should also be easy to set up and easy to debug. If it takes longer than an couple of hours to set up a new developers environment, then the one-step process is likely to be less than optimal. This is with the caveat that if you add or replace team members quarterly or annually this is less of an issue.
I am starting getting used to Eclipse, but I have much more experience with Visual Studio. In Visual Studio it is possible to run auto commands after the build has finished.
Now I am creating a GWT project and several other projects at once in one solution (or workspace) in Eclipse. Some files which are compiled with the GWT project needs to be copied to another location when they have been compiled. I am currently doing this manually and would like to do it automatically. I am not doing it often, since the project works fine in debug mode (...?gwt.codesvr=localhost:9997).
But where is the location for executing a post build command for a GWT project in eclipse? Is it possible?
Just open project properties, choose 'Builders' item and click on 'New...' button.
Good question! I'm using Eclipse since about 2003, and I remember that I also wanted a functionality like that back then. However, I got so used to using ant for any serious build, that I completely forgot about it.
There is some useful ant integration in Eclipse (e.g. the ant view), and if you create your GWT project with webAppCreator you already get a few good ant targets you can build upon.
It would still be nice sometimes to have something more GUI-like to do simple multi-step builds with Eclipse. I haven't found anything like that yet, but it's absolutely possible that it exists, especially as a plugin.