Comments (7)
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.
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.
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.
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.
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.
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.
You were right @fcorneli. Thanks a lot!
from web3j-maven-plugin.
Related Issues (20)
- Problem integrating web3j into maven clean install HOT 1
- Generate meta-data files as well (optional as with bin, abi)
- Why does this plugin keep using solc version 0.4.25?
- Path for ABI & BIN is wrong HOT 1
- Two-dimensional array problem???
- Execution default-cli of goal org.web3j:web3j-maven-plugin:4.10.0:generate-sources failed: ClassLoader.getSystemResource("releases.json") must not be null
- java.net.UnknownHostException: github.com when being offline
- Define solc version
- Error when running "mvn web3j:generate-sources"
- ClassLoader.getSystemResource("releases.json") must not be null HOT 1
- Please add a configuration option for SolidityFunctionWrapperGenerator :: .B, --generateBoth generate both call and send functions.
- Issues generating proxies from external Truffle proj HOT 1
- Can't generateContractWrappers for solidity 0.8.x due result json change format HOT 6
- Generation of code fails when using solidity 0.8.0 HOT 1
- Build Error HOT 4
- add support through solc 0.8.12
- org.json.simple.JSONArray cannot be cast to java.lang.String HOT 1
- web3j plugin solidity source file compile failed with assign solidity version over 0.7.1 HOT 1
- release web3j-maven-plugin for web3j 5.0.0
- Execution generate-sources-web3j of goal org.web3j:web3j-maven-plugin:4.9.4:generate-sources failed: part 'struct OfferItem' is keyword
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from web3j-maven-plugin.