Search code examples
web-servicesmavenintellij-ideaproxy-classes

How to add source files generated in target folder as library in Intellij Idea


I'm trying to checkout a maven project from SubVersion. In the pom.xml file it's specified to generate web service proxy classes in the target folder. Here's the concerned part of the pom.xml file:

          <execution>
                <goals>
                    <goal>wsimport</goal>
                </goals>
                <configuration>

                    <wsdlUrls>                               
                        <wsdlUrl>${basedir}/config/mnpBusinessService.wsdl</wsdlUrl>
                    </wsdlUrls>

                    <packageName>com.mnp.services.business</packageName>
                    <sourceDestDir>${basedir}/target/generated-code/src</sourceDestDir>
                </configuration>
                <id>ws-import-mnpBusinessService</id>
                <phase>generate-sources</phase>
           </execution>

As you can see the maven is instructed to create the generated proxy classes in the ${basedir}/target/generated-code/src directory. When I checkout with NetBeans, a seperate GeneratedCode directory is created as part of the project. And any package inside this directory is available to the main source files. But when I checkout with Intellij Idea,

  1. I have to manually execute install command and second.

  2. The files are indeed created in the specified directory but main source files can't see those packages.

I've tried Project Structure|Modules|MyModule|Dependencies|Add Jars or directories and Project Structure|Libraries|Add|Java|Mydiectoryy. But neither helped. I also tried removing the target folder from Exclude list but that didn't help either. What should I do to be able to import generated proxy classes in Intellij Idea. It's the Ultimate version 2016.2.4.


Solution

  • I ended up creating a module from existing sources, where existing sources folder is my generated-code folder. Then from the Modules|My main module|Dependencies|Add module and chose the just created module. And voila.

    Here are the steps I followed:

    1.

    enter image description here

    2.

    enter image description here

    3

    enter image description here

    4

    enter image description here