Git Product home page Git Product logo

Comments (7)

fcorneli avatar fcorneli commented on July 19, 2024 1

To make it working and behaving like other code generating plugins (jaxws for example), I had to add the following:

<build>
        <plugins>
            <plugin>
                <groupId>org.web3j</groupId>
                <artifactId>web3j-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>generate-sources</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>generate-sources</goal>
                        </goals>
                        <configuration>
                            <soliditySourceFiles>
                                <directory>${basedir}/src/main/solidity</directory>
                                <includes>
                                    <include>**/*.sol</include>
                                </includes>
                            </soliditySourceFiles>
                            <sourceDestination>${basedir}/target/generated-sources/solidity</sourceDestination>
                            <packageName>my.package.name.here</packageName>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>add-source</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>add-source</goal>
                        </goals>
                        <configuration>
                            <sources>
                                <source>${basedir}/target/generated-sources/solidity</source>
                            </sources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

The above should be the default behavior of the web3j-maven-plugin plugin I guess...

from web3j-maven-plugin.

4ntoine avatar 4ntoine commented on July 19, 2024

I've found it works as expected if running mvn compile on the module directly (in ./ethereum directory), not on parent module. Did i miss anything?

PS. Parent module:

<?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>name.antonsmirnov.apptogether</groupId>
    <artifactId>parent</artifactId>
    <version>1.0</version>
    <packaging>pom</packaging>

    <modules>
        ...
        <module>ethereum</module>
        ...
    </modules>

</project>

from web3j-maven-plugin.

h2mch avatar h2mch commented on July 19, 2024

I think you should specify the plugin in the pluginManagement section of the multi-module root pom.

    <modules>
        ...
        <module>ethereum</module>
        ...
    </modules>
 
  <build>
    <!-- In the multi-module root pom, use the pluginManagement to define the version of the maven-plugin -->
    <pluginManagement>
      <plugins>
          <plugin>
                <groupId>org.web3j</groupId>
                <artifactId>web3j-maven-plugin</artifactId>
                <version>0.1.5-SNAPSHOT</version>
          </plugin>
      </plugins>
    </pluginManagement>
  </build>

And in the specific module ethereum, clear the version of the plugin, since it is already defined in the multi-module root pom (the parent).

  <parent>
    <groupId>name.antonsmirnov.apptogether</groupId>
    <artifactId>parent</artifactId>
    <version>1.0</version>
    <relativePath>../</relativePath>
  </parent>
 
  <build>
    <plugins>
      <plugin>
        <groupId>org.web3j</groupId>
        <artifactId>web3j-maven-plugin</artifactId>
        <!-- No version needed here, it is already defined in the multi-module root pom -->
        <configuration>
          <!-- This is where our specific configuration goes -->
        </configuration>
      </plugin>
    </plugins>
  </build>

from web3j-maven-plugin.

4ntoine avatar 4ntoine commented on July 19, 2024

I did what you've suggested - it still does not work. Neither mvn clean generate-sources nor mvn clean web3j:generate-sources on parent module:

$mvn clean generate-sources
...
------------------------------------------------------------------------
[INFO] Building ethereum 1.0
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ ethereum ---
[INFO] Deleting /Users/asmirnov/Documents/dev/src/AppTogether/ethereum/target
[INFO] 
[INFO] --- build-helper-maven-plugin:3.0.0:add-source (default) @ ethereum ---
[INFO] Source directory: /Users/asmirnov/Documents/dev/src/AppTogether/ethereum/target/generated-sources/java added.
[INFO] 
[INFO] --- web3j-maven-plugin:0.1.5-SNAPSHOT:generate-sources (default) @ ethereum ---
[INFO] 
[INFO] ------------------------------------------------------------------------

It works only if i run in the module:

./ethereum asmirnov$mvn clean generate-sources
[INFO] Scanning for projects...
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] Building ethereum 1.0
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ ethereum ---
[INFO] 
[INFO] --- build-helper-maven-plugin:3.0.0:add-source (default) @ ethereum ---
[INFO] Source directory: /Users/asmirnov/Documents/dev/src/AppTogether/ethereum/target/generated-sources/java added.
[INFO] 
[INFO] --- web3j-maven-plugin:0.1.5-SNAPSHOT:generate-sources (default) @ ethereum ---
[INFO] process 'AppetissimoContract.sol'
[INFO] Solidity Compiler found
[INFO] 	Built Class for contract 'AppetissimoContract'
[INFO] 	Built Class for contract 'SafeMath'
[INFO] ------------------------------------------------------------------------

from web3j-maven-plugin.

4ntoine avatar 4ntoine commented on July 19, 2024

That's strange but it still does not work for me. The only thing that i've found is that you've added <id>...</id>. Anything else?

Here is my pom.xml:

      <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>build-helper-maven-plugin</artifactId>
            <executions>
                <execution>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>add-source</goal>
                    </goals>
                    <configuration>
                        <sources>
                            <source>${project.build.directory}/generated-sources/java</source>
                        </sources>
                    </configuration>
                </execution>
            </executions>
        </plugin>

        <plugin>
            <groupId>org.web3j</groupId>
            <artifactId>web3j-maven-plugin</artifactId>
            <version>0.1.5-SNAPSHOT</version>
            <configuration>
                <packageName>name.antonsmirnov.apptogether.ethereum</packageName>
                <sourceDestination>target/generated-sources/java</sourceDestination>
                <nativeJavaType>true</nativeJavaType>
                <soliditySourceFiles>
                    <directory>src/main/resources</directory>
                    <includes>
                        <include>**/*.sol</include>
                    </includes>
                </soliditySourceFiles>
            </configuration>
            <executions>
                <execution>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>generate-sources</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

from web3j-maven-plugin.

fcorneli avatar fcorneli commented on July 19, 2024

You need the build-helper-maven-plugin configuration too, else maven-compiler-plugin won't pick up the generated Java sources.
Also, ${basedir} prefix is required within a multi-module project.

from web3j-maven-plugin.

4ntoine avatar 4ntoine commented on July 19, 2024

You were right @fcorneli. Thanks a lot!

from web3j-maven-plugin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.