Adding IBMs wala.cast.python.ml as dependency - gradle

I am trying to build a project that has this dependency. The corresponding entry in the build.gradle file is like this.
implementation group: 'com.ibm.wala', name:'com.ibm.wala.cast.python.ml', version:'0.0.1-SNAPSHOT'
When I run the command ./gradlew build it failed to find the dependency. There is no point of searching the remote maven, because it is not there. The dependency is a GitHub repo. The error says it looks for two local locations as well.
- file:/home/<user>/.m2/repository/com/ibm/wala/com.ibm.wala.cast.python.ml/0.0.1-SNAPSHOT/maven-metadata.xml
- file:/home/<user>/.m2/repository/com/ibm/wala/com.ibm.wala.cast.python.ml/0.0.1-SNAPSHOT/com.ibm.wala.cast.python.ml-0.0.1-SNAPSHOT.pom
But, when I browse the content in .m2/repository/com/ibm/wala it has a directory ML which has the following.
0.0.1-SNAPSHOT
|--maven-metadata-local.xml
|--ML-0.0.1-SNAPSHOT.pom
maven-metadata-local.xml
maven-metadata-local.xml
<?xml version="1.0" encoding="UTF-8"?>
<metadata>
<groupId>com.ibm.wala</groupId>
<artifactId>ML</artifactId>
<versioning>
<versions>
<version>0.0.1-SNAPSHOT</version>
</versions>
<lastUpdated>20221028162537</lastUpdated>
</versioning>
</metadata>
ML-0.0.1-SNAPSHOT.pom
<?xml version="1.0" encoding="UTF-8"?>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>com.ibm.wala</groupId>
<artifactId>ML</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<properties>
<project-version>0.0.1-SNAPSHOT</project-version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<build-alias>b000</build-alias>
</properties>
<distributionManagement>
<repository>
<id>internal.repo</id>
<name>Temporary Staging Repository</name>
<url>file://${project.build.directory}/mvn-repo</url>
</repository>
</distributionManagement>
<modules>
<module>com.ibm.wala.cast.python</module>
<module>com.ibm.wala.cast.python.jython</module>
<module>com.ibm.wala.cast.python.jython3</module>
<module>com.ibm.wala.cast.python.test</module>
<module>com.ibm.wala.cast.python.jython.test</module>
<module>com.ibm.wala.cast.python.jython3.test</module>
<module>com.ibm.wala.cast.python.ml</module>
<module>com.ibm.wala.cast.python.ml.test</module>
</modules>
</project>
I tried to hack by creating a dir com.ibm.wala.cast.python.ml, then copying the content in ML to it. But it does not work.
Any ideas on how to include this dependency?

Related

Add kotlinx-html-js to kotlin/js project in intellij

I need to add kotlinx-html-js library to a kotlin/js project created with Intellij. I've tried to add maven support and in the pom.xml file write the following:
<?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>com.cillario</groupId>
<artifactId>Demo</artifactId>
<version>1.0-SNAPSHOT</version>
<repositories>
<repository>
<id>jcenter</id>
<name>jcenter</name>
<url>https://jcenter.bintray.com</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlinx</groupId>
<artifactId>kotlinx-html-js</artifactId>
<version>${kotlinx.html.version}</version>
</dependency>
</dependencies>
</project>
As explained here, but it does not work.
Can somebody help me? Thanks a lot.
As for Gradle, I can share with you the following working project:
https://github.com/s1monw1/so_styling_webext/blob/master/build.gradle
The dependecy set looks as follows with 'kotlin-platform-js' plugin applied:
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version"
compile 'org.jetbrains.kotlinx:kotlinx-html-js:0.6.8'
}

Exclude files from a submodule using maven is not working

I have a multi-module project is the following structure:
ROOT
Module A
-- A_pom.xml
Module B depends on Module A
-- src
--- com.mycompany
---- App 1
---- App 2
-- B_pom.xml
-- B_App1_pom.xml
-- B_App2_pom.xml
pom.xml <!-- default parent pom fiel -->
second_parent_pom.xml
The pom.xml
<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>company</groupId>
<artifactId>Parent</artifactId>
<version>0.0.1</version>
<packaging>pom</packaging>
<name>Parent</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<modules>
<module>module-A</module>
<module>module-B/</module>
</modules>
</project>
From ROOT directory mvn package helped me to build both jar files A.jar and B.jar (this include App 1 and App 2)
Now I am looking a way to build both jar files but that will include only App 1. But I have tried the following code but no result.
<build>
[...]
<resources>
<resource>
<directory>${basedir}</directory>
<excludes>
<exclude>/../Module_B/src/com/mycompany/App2</exclude>
</excludes>
</resource>
</resources>
</build>
When I try to specify the B_App2_pom.xml from ROOT directory, it is still pointing to "pom.xml" which make me get the same 2 jar files A.jar and B.jar instead of A.jar and B_App2.jar.
Also, I have tried to create another parent pom file that
The Second Parent Pom
<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>company</groupId>
<artifactId>SecondParent</artifactId>
<version>0.0.1</version>
<packaging>pom</packaging>
<name>SecondParent</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<modules>
<module>module-A/B_App1_pom.xml</module>
<module>module-B/B_App2_pom.xml</module>
</modules>
</project>

Apply a Variable or Profile to a Downloaded Parent Pom

I have a Pom.xml that downloads a Parent Pom for it's <distributionmanagement> from. I am trying to have where the project deploys to be dependent upon a variable within the Parent Pom. Below is my Parent 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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>dev</groupId>
<artifactId>company-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<distributionManagement>
<repository>
<id>Artifactory</id>
<name>Artifactory-releases</name>
<url>http://artifactory:8081/artifactory/${repo}</url>
</repository>
<snapshotRepository>
<id>Artifactory</id>
<name>Artifactory-snapshots</name>
<url>http://artifactory:8081/artifactory/${repo}</url>
</snapshotRepository>
</distributionManagement>
</project>
When I run a mvn deploy I use the command line mvn deploy -Drepo=integration but it does not work. The deploy just places the project in dev and not integration like the variable says to. The parent pom is hosted on artifactory so I believe that because it is downloaded during the deploy the variable isn't being applied to it.

'Go to definition' in a multi-module maven project with module dependencies in IntelliJ

I have a parent module with two child modules (module1 and module2)
module2 has a maven dependency to module1
In module2 I reference a class that's in module1
When I try to jump to the definition of this class, IntelliJ opens the .class file in my maven repository. I expect it to jump to the java class in module1. How can I get IntelliJ to jump this class file?
I'm running IntelliJ IDEA Ultimate 14.0.1
parent 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>test</groupId>
<artifactId>test</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<modules>
<module>module2</module>
<module>module1</module>
</modules>
</project>
module1 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">
<parent>
<artifactId>test</artifactId>
<groupId>test</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>module1</artifactId>
</project>
module2 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">
<parent>
<artifactId>test</artifactId>
<groupId>test</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>module2</artifactId>
<dependencies>
<dependency>
<groupId>test</groupId>
<artifactId>module1</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
This other answer over here at stackoverflow helped me. You essentially have to add module dependencies if they're not already in place.
You have two options:
Way #1:
Build module1 with sources. This way ensures that you will have always consistent source code to used java classes.
To enable build with sources add this to maven plugins:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.1.2</version>
<executions>
<execution>
<id>attach-sources</id>
<phase>verify</phase>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
Way #2:
Add your module1 to module2 via Project structure > Modules > Dependencies > + > 3. Module dependency
Well, it wont be as consistent as way #1 but its much faster to setup, if you are using maven builds. If you are using intellij idea build you can mark this dependency as export to include it in your module1 output dir.

How to override maven property in command line?

I have the following plain pom running by Maven 3.0.4.
<?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>com.example</groupId>
<artifactId>test</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
</project>
I am trying to override default settings in command line like this:
mvn -Dproject.build.finalName=build clean package
But this this is ignored, and I get test-1.0.jar. I've tried to change another properties, like outputDirectory, directory, artifactId, but also failed.
What is the proper way to do this thing?
See Introduction to the POM
finalName is created as:
<build>
<finalName>${project.artifactId}-${project.version}</finalName>
</build>
One of the solutions is to add own property:
<properties>
<finalName>${project.artifactId}-${project.version}</finalName>
</properties>
<build>
<finalName>${finalName}</finalName>
</build>
And now try:
mvn -DfinalName=build clean package

Resources