简体   繁体   English

使用命令行或使用某些Java或Maven代码将目录标记为“ Generated Source Root”?

[英]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". 我需要将目录标记为“ Generated Source Root”。 In IntelliJ, or any other GUI tool, it is easy. 在IntelliJ或任何其他GUI工具中,这很容易。 Is there any other way to mark it using command line or using some java or maven code? 还有其他使用命令行或使用某些Java或Maven代码标记它的方法吗?

If you are using maven - build-helper-maven-plugin does this for you. 如果您使用的是maven,则build-helper-maven-plugin会为您执行此操作。 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 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. 使用此示例将更多的源目录添加到您的项目中,因为pom.xml仅允许一个源目录。

<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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我们可以使用maven命令行在指定目录下构建源代码的war文件吗? - Can we build a war file of source code using maven command line at a specified directory? 使用Maven将依赖项下载到命令行上的目录 - Using Maven to download dependencies to a directory on the command line 如何在包含本机代码的Java应用程序中使用命令行执行Maven主类? - How to execute Maven main class using command line in a Java application containing native code? 使用Maven在命令行上创建Java类和Java包 - Creating java classes and java package on command line using maven 使用Java执行命令并将生成的输出保存在另一个目录中 - execute a command using java and save generated output in another directory 在源代码中使用 selenium 时,如何从命令行编译 java 程序? - How do you compile a java program from the command line while using selenium in the source code? 使用命令行执行Java程序时出现Maven错误 - Maven error when using command line to execute java program 使用命令行创建Java项目时出现Maven错误 - Maven Error While Creating java Project using Command Line 如何使用命令行在 maven 中执行 2 个或多个 java 文件? - How to execute 2 or multiple java file in maven using command line? Maven 和 java:在测试目录中缺少服务的生成代码 - Maven and java: missing generated code for service in test directory
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM