I've already succeed creating java project on vs code. I am installing Java extension pack which is auto install another plugin (like language support by red hat and etc), I am using jdk 8 (jdk1.8.0_241). I am using command palette to create new java project. But my new project doesn't contain pom.xml
Anyway I don't install dedicated maven, only Maven for java extension
I need maven for iReport/jaspers dependencies
You are probably creating a new "Java Project", which is Eclipse-based structure, not Maven.
In the command pallet (Cmd+P on macOS), type Maven and you shall see "Maven: Create Maven Project".
Next step, the extension will ask you which Maven Archetype to use. Select "maven-archetype-quickstart".
You will be asked for input on the terminal after this.
Once the project is generated, type $ code to open a new VSC window.
Done.
You can execute this by cmd:
mvn archetype:generate -DarchetypeGroupId=org.apache.maven.archetypes -DarchetypeArtifactId=maven-archetype-quickstart -DgroupId=com.mycompany.app -DartifactId=my-app
This will generate a maven-archetype-quickstar project.
Related
I want to write java code using the dependency Pi4j and using Intellij on Windows 10. The target platform is a Pi Zero W.
The instructions to develop on remote (Windows 10 in this case) PC say to add the p4j-maven-archetype but don't explain how to use this maven tool within the maven included with Intellij.
I have tried to download the p4j-maven-archetype, extract it, then open Intellij and import p4j-maven-archetype as a project. Then from within Intellij I run the maven goal install so it can be used in other projects.
How would I now create a new project within Intellij using the p4j-maven-archetype that I installed?
Is there a way to package and run it remotely on the Pi from Intellij?
Since this is an archetype that you first need to install into your local Maven repository, follow the steps from corresponding instructions for the archetype project:
Install the archetype to your local .m2 repository
Unzip the archetype file in a folder
cd folder/raspimaven-archetype
mvn install
Then use project generation Maven command:
mvn archetype:generate -DarchetypeCatalog=local
Or use IDE wizard to create the project from the locally installed archetype: New Project | Maven -> Create from archetype:
I am very new to Maven and initial stages where i am exploring how to create a java EE project that i can host in a server. Maintain it through Maven.
First question is asked is how do i create the same structure of a java project that is created by Eclipse when i create a new Maven project in command line in Power Shell?
My findings -
Please see the image snippet
I understand that once we have a project crated. If you want to add modify how your project should build, we can modify that, or we can add new dependencies or many other things from the POM.xml.
But initially atleast it should create the structure of the maven project with a minimal pom.xml right ?
I used the command mvn archetype:generate .... In the Command Prompt the project was created correctly. But I need Maven work in the Power Shell, and this produces an error:
The goal you specified requires a project to execute but there is no POM
in this directory ...
Thanks in Advance
See tutorial. It is pretty good:
https://maven.apache.org/guides/getting-started/maven-in-five-minutes.html
To create a project structure:
mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=1.4 -DinteractiveMode=false
For PowerShell, use quotes for -D, as follows:
mvn -B archetype:generate "-DarchetypeGroupId=org.apache.maven.archetypes" "-DgroupId=com.mycompany.app -DartifactId=my-app"
I am using IntelliJ community version and I am trying to create jersey project,but my intelliJ is not allowing this feature.
mvn archetype:generate -DgroupId=com.mkyong.rest -DartifactId=RESTfulExample
-DarchetypeArtifactId=maven-archetype-webapp -DinteractiveMode=false
But as here, I created maven project from command prompt and I saw ,I needed to add extra support for the IDE.Since this command as given down in figure is for Eclipse,What is the command should I run for IntelliJ to change it so that IntelliJ will support it?
I'm working with multiple projects in Eclipse. because I want to automate the building I want to script the building process.
Unfortunately I cannot do the same actions on the commandline as in Eclipse.
So a common problem is that when a new function from a referenced project is used, I cannot build the project on the commandline with mvn. I use the command:
mvn clean install -U
But this command will give a build failure until I do a Eclipse Maven Update from the eclipse GUI. After that I can build the project again.
I also tried all the other commands I came across Stackoverflow:
mvn eclipse:eclipse
mvn dependency:resolve
So I just want to that Maven Update command in eclipse from the commandline so I can build from the commandline. If anyone could tell me what I'm doing wrong that would be awesome.
Thx in advance
Update for more clarification:
The project structure is:
Rest-service, Framework-service, Framework-model
Framework-model is referenced in the pom file by Framework-service and Framework-service is referenced by Rest-service. The other projects are not relevant to the problem.
When a function is added to Framework-model and used in Rest-service it gives an compilation error in eclipse and when I build with mvn clean install -U, although Maven install in eclipse is succesful but I think it is still using the old compiled code. After a Maven Update command in eclipse the compilation error is gone. And mvn clean install -U from the commandline also works.
How could I do a Maven Update command in the commandline? If mvn clean install -U should also do a Maven Update command, what settings should I check?
Another update: So this weekend I tried different things and running mvn compile before the mvn clean install -U command gives a different output. And finds the new function. But as I read maven, I thought install should also do the previous steps. How is this possible?
Eclipse's Maven plugin uses the maven version configured in Preferences/Maven/User settings. If you have a different version of maven in your Eclipse's settings than the one on your PATH variable, you could have different outputs. Maybe try and check that.
What is the command that m2eclipse runs when you
highlight a project -> Menu Project -> Clean -> Select anything -> Ok ?
It then goes on to "Building Workspace".
What is the command that allows it to do so?
The reason I am asking is that I am trying to do this from outside Eclipse, from the command line. I am trying to automate all maven stuff in a Groovy script. I am on Windows xp.
EDIT:
Also, the command update maven dependencies would be nice to have as well.
Thanks!
Maven-invocations are put in the Run and Debug menus. Just building the workspace does not run maven - it just does all the work Eclipse needs to do to know your files.
For your purposes these will suffice for the command line build:
cd /to/where/pom.xml/is
mvn clean
mvn install
No commands are directly run. Instead, the m2e plugin uses the configuration in the pom to create equivalent configurations in eclipse.
For example, if you change the source directories it will update the eclipse source directories for the java builder. If you change the target directories for the source compilation, it'll ensure that when you do a Project -> Clean, the plugin knows which directories to clean.
If you are trying to do this though a scripting language, I would recommend just running commands on the command line. The alternative would be to add the maven libraries to the classpath and to use them.