Maven Generated Sources Folder Not Picked Up by Eclipse

I am migrating my build from Ant to Maven. The Ant construct used to compile the "code generator" executes this "code generator", which creates a set of Java and C code. Then he took the generated Java code and compiled it along with some additional code to create a single jar.

I reproduced this in Maven quite easily and works well when I start from the command line, but Eclipse complains and gives me an error related to the pom file

Could not find {group.id}: {artifact.id}: pom: 1.0.0-SNAPSHOT at http: // {our internal site repository} / nexus / content / groups / public was cached in the local repository, permission will not be reloaded until the snapshot refresh interval has expired, or the updates are forced

where group.id and artifact.id are the group and artifact identifier of my code generator plugin

and any code that refers to the generated code is also not compiled.

My maven build consists of

  • generator project containing only Java code for the code generator.

  • generator plugin project containing only code to wrap the generator as a Maven plugin. It depends on the design of the generator.

  • an xyz project that uses a plugin to generate code. The code falls into the target / generated-sources / xxx folder of this project. I configured the build-helper-maven plugin according to Maven with several src directories to include this additional source directory.

If you manually add the generated source folder to the Eclipse build path, all the errors are related to the lack of code in this project, but not for any downstream projects, and the "Failure to find ..." error above.

What puzzles me a bit is that this applies to ...: pom: 1.0.0-SNAPSHOT, when in fact my plugin generator is defined as a maven plugin.

Is this a reasonable approach?

Why am I getting the "Inability to find ..." error?

Why is Eclipse not collecting my folders of generated sources?

I should also say that I have a m2e plugin and a m2e connector for the build-help-maven-plugin installed in my Eclipse IDE.

+4
source share
2 answers

It seems like a problem while loading lib from the repository. I already had the same error message.

  • Have you looked at your local repository?

    Go to the .m2 folder and find /nexus/content/groups/public . If there is a folder, open it and check if the library is loaded correctly. If not, try deleting the folder and try running mvn install to force the lib to load.

    In Eclipse, run Right button > Maven > Update Project too.

  • Are you using a local repository like Artifactory, right? Also find lib in the repo1-cache (or similar) folder. See if there is a jar.

  • Are you behind any firewall or proxy server?

0
source

Using eclipse Indigo3.7, I found that this works well using Spring 3.1.1, which also has version 3.0.6. As soon as I installed the plugins and placed the pom in the desired area, turned on argline and endorseddirs so that the java sources were placed in the target / generate-sources / cxf folder, then maven would generate the sources normally.

....

  <properties>... <dependencyManagement> <dependencies>..... </dependencyManagement> <dependencies> <dependency>.... </dependencies> <!-- *************************** Build process ************************************* --> <build> <finalName>projName</finalName> <plugins> <!-- Force Java 6 --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.4</version> <configuration> <source>1.6</source> <target>1.6</target> </configuration> </plugin> <!-- Deployent on AS from console <plugin> <groupId>org.jboss.as.plugins</groupId> <artifactId>jboss-as-maven-plugin</artifactId> <version>${version.jboss.as.maven.plugin}</version> </plugin> --> <!-- wildbill added tomcat plugin --> <plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <version>2.0</version> </plugin> <!-- Surefire plugin before 2.9 version is buggy. No need to declare here, it being referenced below w/ the version <plugin> <artifactId>maven-surefire-plugin</artifactId> <version>2.12</version> </plugin> --> <!-- developer added these --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <compilerArguments> <endorseddirs>target/generated-sources/cxf</endorseddirs> </compilerArguments> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.12</version> <configuration> <forkMode>once</forkMode> <argLine>-Djava.endorsed.dirs=target/generated-sources/cxf</argLine> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <compilerArguments> <endorseddirs>target/generated-sources/cxf</endorseddirs> </compilerArguments> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <forkMode>once</forkMode> <argLine>-Djava.endorsed.dirs=target/generated-sources/cxf</argLine> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <configuration> <artifactItems> <artifactItem> <groupId>javax.xml.bind</groupId> <artifactId>jaxb-api</artifactId> <version>2.2</version> </artifactItem> <artifactItem> <groupId>javax.xml.ws</groupId> <artifactId>jaxws-api</artifactId> <version>2.2</version> </artifactItem> </artifactItems> <outputDirectory>target/generated-sources/cxf</outputDirectory> </configuration> </plugin> </plugins> </build> <!-- *********************** Profiles ************************************ --> <profiles> <profile> <!-- When built in OpenShift the 'openshift' profile will be used when invoking mvn. --> <!-- Use this profile for any OpenShift specific customization your app will need. --> <!-- By default that is to put the resulting archive into the 'deployments' folder. --> <!-- http://maven.apache.org/guides/mini/guide-building-for-different-environments.html --> <id>projName</id> <build> <plugins> <plugin> <groupId>org.apache.cxf</groupId> <artifactId>cxf-codegen-plugin</artifactId> <version>2.5.2</version> <executions> <execution> <id>process-sources</id> <phase>generate-sources</phase> <configuration> <fork>once</fork> <additionalJvmArgs>-Djava.endorsed.dirs=target/generated-sources/cxf</additionalJvmArgs> </configuration> <goals> <goal>wsdl2java</goal> </goals> </execution> </executions> <dependencies> <dependency> <groupId>com.sun.xml.bind</groupId> <artifactId>jaxb-impl</artifactId> <version>2.2</version> </dependency> <dependency> <groupId>com.sun.xml.bind</groupId> <artifactId>jaxb-xjc</artifactId> <version>2.2</version> </dependency> </dependencies> </plugin> <!-- Actual war created in default target dir --> <plugin> <artifactId>maven-war-plugin</artifactId> <version>2.2</version> </plugin> </plugins> </build> </profile> </profiles> 

If your wsdl folder is in $ {basedir} / src / main / resources, it will find it automatically

Hope this helps!

0
source

Source: https://habr.com/ru/post/1413911/


All Articles