简体   繁体   中英

Mark a directory as “Generated Source Root” using command line or using some java or maven code?

I need to mark a directory as "Generated Source Root". In IntelliJ, or any other GUI tool, it is easy. Is there any other way to mark it using command line or using some java or maven code?

If you are using maven - build-helper-maven-plugin does this for you. Look at the execution section specifically in the plugin, there you can add you directory under source tag.

https://www.mojohaus.org/build-helper-maven-plugin/usage.html

Quoting directly from the link above:

Use this example to add more source directories to your project, since pom.xml only allows one source directory.

<project>
  ...
  <build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <version>3.0.0</version>
        <executions>
          <execution>
            <id>add-source</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>add-source</goal>
            </goals>
            <configuration>
              <sources>
                <source>some directory</source>
                ...
              </sources>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM