小编The*_*ist的帖子

Maven中如何处理生成源的依赖关系?

在过去的几天里,我一直在尝试使用openapi-generator-maven-plugin. 然而,compile当 Maven 意识到生成的代码刚刚引入的第三方依赖项尚未解决时,它就会在 -Phase 中失败。由于代码生成本身有效,我的问题似乎相当普遍,并且与生成代码后发生的情况有关。

这是一个示例 POM,其中包含有关如何设置插件的自述文件的复制粘贴内容:

<?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>org.example</groupId>
  <artifactId>openapi-generator-maven-plugin-error-demo</artifactId>
  <version>1.0-SNAPSHOT</version>

  <properties>
    <maven.compiler.source>8</maven.compiler.source>
    <maven.compiler.target>8</maven.compiler.target>
  </properties>

  <build>
    <plugins>
      <plugin>
        <groupId>org.openapitools</groupId>
        <artifactId>openapi-generator-maven-plugin</artifactId>
        <!-- RELEASE_VERSION -->
        <version>5.0.0</version>
        <!-- /RELEASE_VERSION -->
        <executions>
          <execution>
            <goals>
              <goal>generate</goal>
            </goals>
            <configuration>
              <inputSpec>https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v2.0/json/petstore.json</inputSpec>
              <generatorName>java</generatorName>
              <configOptions>
                <sourceFolder>src/gen/java/main</sourceFolder>
              </configOptions>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

</project>
Run Code Online (Sandbox Code Playgroud)

运行mvn clean compile应该会生成源代码,而且确实如此。然而,一旦maven-compiler-plugin生成代码后立即启动,它就会在生成的代码中看到新引入的包和符号引用,从而失败。

所以我试图弄清楚如何在生成之后、编译之前安装所述依赖项,但完全失败了。我怀疑我需要使用 maven-depndcies-plugin,但由于我对 Maven 的了解有限,而且对其插件如何工作的了解更有限,我完全迷失了。我尝试将其添加maven-dependency-plugin到我的 POM 中,但 Maven 完全忽略它并且根本不运行它。我尝试将resolve目标与compile阶段绑定,但没有成功。

我本以为 …

java code-generation maven

6
推荐指数
0
解决办法
1645
查看次数

如何使用 TypeScript 正确导出 React 组件库中的 SVG

我正在将 React 应用程序的核心组件提取到一个单独的组件库中,以供其他客户端应用程序使用。这些组件使用 SVG 图标,该图标已经通过 babel-loader 在原始应用程序中运行。

\n\n

然而,由于组件是用 Typescript 编写的,据我所知,我需要ts-loader该库正常工作,即使我无法测试它,因为我什至无法编译该库。为了能够导出 SVG,我另外babel-loaderbabel-plugin-named-asset-import.

\n\n

这是我的项目结构:

\n\n
.\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 config\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 webpack.config.js\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 global.d.ts\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 index.ts\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 package.json\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 package-lock.json\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 src\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 assets\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 icons\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x82\xc2\xa0\xc2\xa0     \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 index.d.ts\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x82\xc2\xa0\xc2\xa0     \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 index.ts\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x82\xc2\xa0\xc2\xa0     \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 upload.svg\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 bar\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 index.ts\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 foo\n\xe2\x94\x82\xc2\xa0\xc2\xa0     \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 index.ts\n\xe2\x94\x82\xc2\xa0\xc2\xa0     \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 Stuff.ts\n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 tsconfig.json\n
Run Code Online (Sandbox Code Playgroud)\n\n

webpack.config.json:

\n\n
const path = require("path");\n\nmodule.exports = {\n  entry: "./index.ts",\n  module: {\n    rules: [\n      {\n        test: /\\.tsx?$/,\n        use: {\n          loader: "ts-loader",\n        },\n        exclude: …
Run Code Online (Sandbox Code Playgroud)

typescript reactjs webpack babel-loader

5
推荐指数
1
解决办法
1万
查看次数