1

I am complete new to IntellijIdea and i am looking for some step-by-step process to set up a basic project.

My project depends on Maven + Jaxb classes so i need a Maven project so that when i compile this project, the JAXB Objects are generated by Maven plugins. Now i started like this

  1. I created a blank project say MaJa project
  2. Added Maven Module to it
  3. Added following settings in POM.XML
 <?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>MaJa</groupId>
    <artifactId>MaJa</artifactId>
    <version>1.0</version>

    <dependencies>
        <dependency>
            <groupId>javax.xml.bind</groupId>
            <artifactId>jaxb-api</artifactId>
        </dependency>
        <dependency>
            <groupId>com.sun.xml.bind</groupId>
            <artifactId>jaxb-impl</artifactId>
            <version>2.1</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>jaxb2-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>xjc</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <schemaDirectory>${basedir}/src/main/resource/api/MaJa</schemaDirectory>
                    <packageName>com.rimt.shopping.api.web.ws.v1.model</packageName>
                    <outputDirectory>${build.directory}</outputDirectory>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>
  1. First of all, is it right settings ?

  2. I tried clicking on Make/Compile 'MaJa' from Project > Right Click Menu and it didn't do anything.

I will be looking forward to yoru replies.

Em Ae
  • 8,167
  • 27
  • 95
  • 162

1 Answers1

2

You must click not on Make/Compile 'MaJa'
1) You must choose one of maven Build Lifecycle phases here (not less then Compile).
2) Set path to maven in settings.
3) Add version for jaxb-api artifact

enter image description here

I add shiporder.xsd to directory /src/main/resource/api/MaJa and java classes were generated well

[jaxb2:xjc]
Generating source...
parsing a schema...
compiling a schema...
com\rim\shopping\api\web\ws\v1\model\ObjectFactory.java
com\rim\shopping\api\web\ws\v1\model\Shiporder.java
Ilya
  • 29,135
  • 19
  • 110
  • 158
  • Excellent. Though i ran into a problem where Maven complained that annotation are not supported for version 1.3. so i added following settings `maven-compiler-plugin1.71.7` **Now one more question** shall i generate the classes (.java files) in `${build.directory}` or should it be in `${build.sourceDirectory}`. Just wanted to confirm since you didn't point it out. – Em Ae Sep 27 '12 at 03:57
  • They should be in `${build.directory}`, becouse they must be removed and regenarated every new build – Ilya Sep 27 '12 at 06:28
  • if i keep them in build.directory, then the IDE wouldn't be able to see those files since they aren't in `src` directory hence the auto-completion/errors while writing code wouldn't be possible. Not sure, haven't tried yet but you know what i am saying ? – Em Ae Sep 27 '12 at 14:24
  • **EDIT**: Yup, those files aren't visible in IDE at the time of codeing – Em Ae Sep 27 '12 at 14:34
  • I am using NetBeans and NetBeans see generated files well. Don't know how make IDEA to see generated classes – Ilya Sep 27 '12 at 14:46