I use NetBeans 11.0 and Java 11 for my Modular project. How I could rename already created module without deleting any file inside of him?
There isn't refactoring for modular projects and modules. Any suggestion would be appreciated.
Build tool is Ant.
I assume you are using Maven. In your pom.xml you can set the name of the project in the name-tag:
<project ...>
<name>My project name</name>
...
</project>
For Ant projects have a look at this answer.
Related
I'm trying to generate Java unit tests using Eclipse's JDT. Part of that is determining the classpath that pertains to a particular Java class.
I imported a Maven project named jaffa-framework into Eclipse. Jaffa-framework has several Maven modules, including jaffa-api. Each of the submodules has its own pom.xml. I can build jaffa-framework and its submodules with no problem using Maven from within Eclipse (although it will not build using Project -> Build Project).
<project ...
<artifactId>jaffa-framework</artifactId>
...
<profiles>
<profile>
<id>normal</id>
<modules>
<module>jaffa-api</module>
...
</modules>
</profile>
</profiles>
...
</project>
When I import jaffa-framework into Eclipse as a Maven project, I see the following in the UI:
A Java project: jaffa-framework
Two Folders/IPackageFragmentRoots for jaffa-api:
jaffa-api/src/main/java and jaffa-api/src/test/java
One "plain" folder: jaffa-api
This structure looks weird to me. I expected to see something more like:
jaffa-framework
jaffa-api
jaffa-api/src/main/java
jaffa-api/src/test/java
Perhaps I did something wrong while importing? If you have ideas, please let me know.
If I select a Java file within jaffa-api/src/main/java, I can use JDT to navigate to the jaffa-framework project and get its classpath using javaProject.getResolvedClasspath(true); however, what I really need is the classpath for jaffa-api.
The jaffa-api folder contains a pom file, a .project file, and a .classpath file. I don't see an easy way to navigate to it using JDT, and because it is a folder, I don't see how I could obtain the classpath programmatically using JDT.
I'm also wondering why jaffa-api looks like a plain folder, instead of something more project-like. Eclipse must know that it is some kind of subproject, because the folder contains .classpath and .project files.
Please tell me how I can access the classpath information of jaffa-api using JDT, and/or how I can correct my project set up.
There was something screwy about my original project creation. I'm not sure what.
I solved my problem by deleting my jaffa-framework project by right-clicking on it and choosing "Delete" from the menu. I re-imported the project using File -> Open Projects from File System. I'm guessing the key thing to notice here is that the "Search for nested projects" box is checked. After the project was reloaded, both jaffa-framework and jaffa-api appeared as projects.
Currently I have perforce that I am importing my project into eclipse from. After I import my project into eclipse I right click on the project go to configure and convert to maven project. After doing all of this I do NOT have autocomplete for the code working and I do NOT have ctrl+click working.
System Specs:
OS: Windows 7 x64
RAM: 8gb
CPU: Intel core i5
HDD: 128gb SDD
Eclipse Version: Juno 4.2 JavaEE
Maven m2e Version: 1.1.0
Perforce Version: 2012.2.486944
Attempts at a Fix
I have noticed that when I right click on my project and look to go to Java Build Path it does not exist.
Under my right click menu properties and under builders I only have "Maven Project Builder"
I have tried to add the proper <buildCommand> for the java builder and the proper <natures> in the .project file. This does NOT fix my issue but does add the Java Build Path I couldn't see in 1. (below is my unaltered .project file)
I have navigated to the .metadata>.plugins and deleted the org.eclipse.jdt.core to eclipse rebuild its indices.
Error Received when trying ctrl+click autocomplete or a right click>References>Workspace
The resource is not on the build path of a Java project
.project file
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>project</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>
Is there something simple that I have overlooked, or a step that I forgot to do? Any help regarding this issue would be great.
(*I have searched though issues relating to the ctrl+click and the autocomplete but none of the solutions that I have found have helped and none seem to match the eclipse+perforce+maven issue, but sorry in advance if this topic was covered in a different post)
Alright here is what I did and found out.
I started over with a new copy of eclipse 4.2 EE and redownloaded all of the plugins that I needed: m2e and perforce
If you have a flat Maven Project
Import the project from perforce, right click on the project>configure>Convert to Maven Project
Converting the flat project to a Maven Project indexed everything allowing for the ctrl+click/ctrl+space functionality
If you have a multi module Maven Project
Check out the project using the perforce plugin into your workspace
Import said project as an Existing Maven Project
Eclipse/Maven will automatically find all of the poms underneath the parent directory and build/index your workspace
After that same as above the ctrl+click/ctrl+space functionality should work
My oversight was that the project I was having issues with I did not realize was a multi module maven project and importing it from perforce and trying to convert the parent folder to a maven project did not cause maven to look at all of the poms in the parent's sub-directories. Hope this helps anyone else having this issue.
The way I use Perforce+Maven+Eclipse is to first import my projects as Maven first, and then later right-click the project > Team > Share Project by linking it against my perforce repository. I find that Eclipse doesn't properly manage projects with Maven if I don't directly import it as a Maven project from the start.
i'm new in the world of GAE. I 'm using eclipse and GAE's SDK, i can deploy to the cloud with the GAE icon and everything is fine. The problem arises when I have to import the infinite number of dependency, then I want to use maven for that. I discovered that there is a special GAE maven plugin called:
maven-gae-plugin
Can I use regular maven only to fetch dependencys or I have to use the GAE special plugin to do this?
Thanks
You'll need to define a pom.xml for the project which declares the dependencies.
When you build with maven the dependencies will be downloaded from the remote repositories and stored in you local repository ${userhome}/.m2/repository.
The maven build will also bindle the dependencies in your war file.
The easiest way to get started is by creating a project structure using an archetype.
There are 2 archetypes that I've tried for gae so far:
gae-archetype-gwt, which is built adjacent to the gae-maven-plugin, see this article.
gae-eclipse-maven-archetype, see this article and also note the link at the top of the article for the helios update.
As the name suggests gae-eclipse-maven-archetype has better support for eclipse, I have been finding that the configurations for maven and eclipse have been clashing with each other, which gae-eclipse-maven-archetype goes a long way to alleviate.
If your current project is not using the maven directory structure, then you are going to have an uphill battle. Maven projects are easier to configure if you try to fit in with the defaults which are largely sensible options, rather than going against the grain and having to override all of the default configuration options.
There is no reason you can't use maven for it's dependency management only. The GAE dependencies are all in maven central.
There is a write up about how to set it up here
I personally use the eclipse plugin in dev and the maven plugin when running under continuous integration.
The main gotcha is to follow the advice about ensuring that the maven dependencies are the last thing in your build path under the GAE plugin dependencies.
Add the following to your pom.xml, modifying it to your needs:
<project>
...
<properties>
...
<com.google.appengine-version>1.6.4</com.google.appengine-version>
...
</properties>
<dependencies>
...
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-api-1.0-sdk</artifactId>
<version>${com.google.appengine-version}</version>
</dependency>
...
</dependencies>
...
</project>
In case you need any additional GAE-related artifacts besides appengine-api-1.0-sdk, have a look for those artifacts in The Central Repository under com.google.appengine, then add them to your pom.xml's dependencies list.
I am creating a new maven project from an eclipse plugin.
As it seems to me a bad idea to hardcode pom.xml to my plugin. Is there any way to generate this programmatically such that the plugin will be more maintainable ?
Also creating the maven project structure from the plugin on my own seems to be a bad idea too !
Is there any api to do this tast ? (creating a maven project, adding my dependency to it)
What I am currently doing is to create folders, write a .classpath file (hardcoded) , injecting maven nature to .project file and now trying to generate the pom.xml.
Seeing a pom.xml I thought writing one plugin for th ecurrent version of maven won't do a good job.
Not sure what you want/need to do exactly but you could maybe use the MavenXpp3Writer#write() method from the Maven Model API to write a POM from a given Model.
Sounds like you are trying to do the job of maven archetypes
mvn eclipse:eclipse
I've recently been asked to mavenize an existing project, and I don't know exactly what that means. On the maven website it outlines how to create a maven project from scratch, but what if I've already got a substantial amount of code?
I'm comfortable working on the command line or in Eclipse/Netbeans. I know there are a lot of plugins for the 2 IDE's that make this kind of thing easier but I don't know where to start.
Is there anything more to it than just writing a pom file that has all the dependencies in it?
To "Mavenize" simply means to write a POM (and possibly move code around) so that it builds in Maven.
Often the easiest way to do this is to restructure your code slightly so it matches Maven conventions (e.g. move "sources" to "src/main/java", and explicitly split up separate modules). You can ignore the conventions, and tell Maven how you're storing your classes etc., but in general a small bit of pain up front to make most of Maven then work "out of the box" is worth investing in.
Chances are the vast majority of your Ant (or similar) file is boilerplate, which was the idea behind Maven in the first place. However, there may be some bespoke stuff in there (e.g. test classes that start with "TestIntegration" should only be run on nightly builds) which you'll need to reproduce in Maven.
But yeah, in general it means to take the existing functionality of a build, and reproduce that same functionality using Maven.
It means to reorganise the projects code and resources to conform to the maven model. This use of 'convention over configuration' allows the standard maven tools to operate on your codebase.
In addition to what is said.
One can always convert an existing java project to a maven project with eclipse IDE, m2eclipse plugin supports such feature or option, as follows:
After installing m2eclipse plugin and restarting eclipse.
Right click java project --» configure --» convert to maven
You will have a generated pom to start with, almost always it needs modifications to match the projects dependencies and repositories if those dependencies aren't in the maven central repo.
Simply, just add the pom.xml file under your root (context) project folder. This will make your project as Mavenize project. Once you have added the pom file, then you can execute maven build life cycle commands from IDE terminal.
These maven life cycle commands associated with default maven plugins. So, below given basic declarations enough to start any simple Java project with Maven build.
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>AsyncService</artifactId>
<version>1.0-SNAPSHOT</version>
</project>