I am trying to get Apache commons-io-2.4.jar installed directly using maven.
The POM snippet is as follows. Can anyone help me make it work?
POM Snippet:
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>Maven Repository Switchboard</name>
<url>http://repo1.maven.org/maven2</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
</dependencies>
Related
I am creating parent-pom. There we are defining build->plugin->dependencies.
It can fetch dependencies from maven but it couldn't fetch dependencies from our internal Maven repository. getting below error
[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-antrun-plugin:1.2:check (validate) on
project parent-pom: Execution validate of goal
org.apache.maven.plugins:maven-antrun-plugin:1.2:check failed: Plugin
org.apache.maven.plugins:maven-antrun-plugin:1.2 or one of its
dependencies could not be resolved: Could not find artifact
org.tools:build-tool:jar:1.0 in central
(https://repo.maven.apache.org/maven2) -> [Help 1]
It is trying to pull dependency from https://repo.maven.apache.org/maven2 instead of our internal Maven repository. I have configured repositories and dependencyManagement still it is trying to fetch from https://repo.maven.apache.org/maven2 instead of going to our internal repositories.
pom.xml
<?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.global</groupId>
<artifactId>parent-pom</artifactId>
<version>1.0.0</version>
<packaging>pom</packaging>
<repositories>
<repository>
<id>archiva.global</id>
<name>Internal Release Repository</name>
<url>https://archiva.global.com/repository/internal</url>
</repository>
<repository>
<id>archiva.snapshots</id>
<name>Internal Snapshots Repository</name>
<url>https://archiva.global.com/repository/snapshots</url>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>
<distributionManagement>
<repository>
<id>archiva.internal</id>
<name>Internal Release Repository</name>
<url>https://archiva.global.com/repository/internal</url>
</repository>
<snapshotRepository>
<id>archiva.snapshots</id>
<name>Internal Snapshots Repository</name>
<url>https://archiva.global.com/repository/snapshots</url>
</snapshotRepository>
</distributionManagement>
<project>
...
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.2</version>
...
<dependencies>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
<version>1.7.1</version>
</dependency>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant-launcher</artifactId>
<version>1.7.1</version>
</dependency>
<dependency>
<groupId>org.tools</groupId>
<artifactId>build-tool</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
...
</project>
Is there anything I missed? Only build plugin dependencies are not resolved where as project dependencies are getting resolved from our internal repository.
It is the default behavior of maven.
When defining <repository> .... </repository> make sure to override the <id>central</id> with your internal repository. If you don't do so, maven will still contact maven central to resolve dependencies and not work without proper proxy settings if you are behind a VPN. The below listing will fetch all your deps from your internal repository.
<repositories>
<repository>
<id>central</id>
<name>Internal Release Repository</name>
<url>https://archiva.global.com/repository/internal</url>
</repository>
<repository>
<id>archiva.snapshots</id>
<name>Internal Snapshots Repository</name>
<url>https://archiva.global.com/repository/snapshots</url>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>
For downloading the plugins from your internal repository
<pluginRepositories>
<pluginRepository>
<id>central</id>
<name>Central Internal Repo</name>
<url>https://archiva.global.com/repository/internal</url>
<layout>default</layout>
<snapshots>
<enabled>false</enabled>
</snapshots>
<releases>
<updatePolicy>never</updatePolicy>
</releases>
</pluginRepository>
I'm developing a task to use Spring Cloud Data Flow, but I can't see the execution parameters of my task (which is a Spring Boot application) or how to execute the task.
I am importing my application as a base and as the project as a base: spring-cloud-starter-task-timestamp
This is my pom, I made this using Spring Initializr and then using the timestamp-task application for tweaking.
<groupId>teste</groupId>
<artifactId>scdf-neo4j-task</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>scdf-neo4j-task</name>
<description>scdf-neo4j-task</description>
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-task-parent</artifactId>
<version>2.3.0-SNAPSHOT</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<spring-cloud.version>Hoxton.SR5</spring-cloud.version>
<start-class>teste.scdf.Neo4jTaskApplication</start-class>
<skipInstall>true</skipInstall>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-task</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.neo4j.driver</groupId>
<artifactId>neo4j-java-driver</artifactId>
<version>4.0.1</version>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-task-dependencies</artifactId>
<version>2.3.0-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/libs-snapshot-local</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/libs-milestone-local</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>spring-releases</id>
<name>Spring Releases</name>
<url>https://repo.spring.io/release</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>spring-libs-release</id>
<name>Spring Libs Release</name>
<url>https://repo.spring.io/libs-release</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>spring-milestone-release</id>
<name>Spring Milestone Release</name>
<url>https://repo.spring.io/libs-milestone</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-releases></id>
<name>Spring Releases</name>
<url>https://repo.spring.io/libs-release</url>
</pluginRepository>
<pluginRepository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/libs-snapshot-local</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/libs-milestone-local</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</project>
This is my main Spring Boot class that implements CommandLineRunner:
#Log
#EnableTask
#SpringBootApplication
#EnableConfigurationProperties({Neo4jTaskProperties.class})
public class Neo4jTaskApplication
{
#Autowired
public Neo4jTaskProperties neo4jTaskProperties;
public static void main(String[] args)
{
SpringApplication.run(Neo4jTaskApplication.class, args);
}
#Bean
public CommandLineRunner commandLineRunner()
{
return args ->
{
Driver driver = GraphDatabase.driver(
neo4jTaskProperties.getUri(),
AuthTokens.basic(
neo4jTaskProperties.getUsername(),
neo4jTaskProperties.getPassword()
)
);
try (Session session = driver.session())
{
session.writeTransaction(transactionWork ->
{
ResultSummary resultSummary = transactionWork.run(neo4jTaskProperties.getCommand()).consume();
return resultSummary;
});
}
};
}
}
And this is my properties class:
#Data
#ConfigurationProperties("neo4j")
public class Neo4jTaskProperties {
private String uri;
private String username;
private String password;
private String command;
}
How can I solve this problem?
You need to add your task application properties into an application metadata that Spring Cloud Data Flow knows how to extract and make them available.
You can refer this page that walks you through how to add metadata.
Also, you can check this sample configuration as a reference on how to add such metadata.
I am currently involved in a project managed by maven and the project structure is a mess. So I tried to update the pom files and settings.xml first.
However after I switched in settings.xml:
<repository>
<id>Spring IO Releases</id>
<name>SpringSource Enterprise Bundle Repository - SpringSource Bundle Releases</name>
<url>http://repository.springsource.com/maven/bundles/release</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>Spring IO Snapshots</id>
<name>SpringSource Enterprise Bundle Repository - External Bundle Releases</name>
<url>http://repository.springsource.com/maven/bundles/snapshot</url>
<releases>
<enabled>false</enabled>
</releases>
</repository>
to:
<repository>
<id>Spring IO Snapshots</id>
<url>http://repo.spring.io/libs-snapshot/</url>
<releases>
<enabled>false</enabled>
</releases>
</repository>
<repository>
<id>Spring IO Releases</id>
<url>http://repo.spring.io/libs-release/</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
And changed my dependency from:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>org.springframework.XXX</artifactId>
<version>${spring-version}</version>
</dependency>
to
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-XXX</artifactId>
<version>${spring-version}</version>
</dependency>
However it didn't work. What is the difference between these two dependencies?
I have checked inside the Jar files and only obvious thing is springframework.XXX artifacts are build 1 month before spring-XXX artifact contents.
How can i use selenium and sikuli in one pom.xml ?
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.45.0</version>
</dependency>
<dependency>
<groupId>com.sikulix</groupId>
<artifactId>sikulixapi</artifactId>
<version>1.1.0-SNAPSHOT</version>
</dependency>
sikuli is in :
<repository>
<id>com.sikulix</id>
<name>com.sikulix</name>
<url>https://oss.sonatype.org/content/groups/public</url>
<layout>default</layout>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
but adding this repo, makes maven to look there for selenium too
is it possible to link two different dependencies from two different repositories ?
Maven looks for artifacts (selenium, sikulixapi, ..) in all defined repositories.
You can define two: com.sikulix and the standard one:
<repositories>
<repository>
<id>com.sikulix</id>
<name>com.sikulix</name>
<url>https://oss.sonatype.org/content/groups/public</url>
<layout>default</layout>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
<repository>
<id>central</id>
<name>Maven Repository Switchboard</name>
<layout>default</layout>
<url>http://repo1.maven.org/maven2</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
I have a Data project and an EJB project created. Now I have created another Arquillian project for testing the above two with it using JUnit. I have created pom.xml file
<?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.arquillian.unit.test</groupId>
<artifactId>arquillian-test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>arquillian-test</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jboss.arquillian</groupId>
<artifactId>arquillian-bom</artifactId>
<version>1.1.1.Final</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
<repositories>
<repository>
<id>jboss-public-repository-group</id>
<name>JBoss Public Repository Group</name>
<url>http://repository.jboss.org/nexus/content/groups/public/</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</snapshots>
</repository>
<repository>
<id>jboss-deprecated</id>
<name>JBoss Deprecated</name>
<url>https://repository.jboss.org/nexus/content/repositories/deprecated/</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>jboss-maven2-brew</id>
<name>JBoss Maven 2 Brew Repository</name>
<url>http://repository.jboss.org/maven2-brew/</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>jboss-public-repository-group</id>
<name>JBoss Public Repository Group</name>
<url>http://repository.jboss.org/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
<testResources>
<testResource>
<directory>FocalColectEJB/com/focalinfo/service</directory>
</testResource>
</testResources>
</build>
<dependencies>
<dependency>
<groupId>org.jboss.spec</groupId>
<artifactId>jboss-javaee-6.0</artifactId>
<version>1.0.0.Final</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
</dependency>
</dependencies>
<profiles>
<profile>
<id>jbossas-managed-5.1</id>
<dependencies>
<dependency>
<groupId>org.jboss.arquillian.container</groupId>
<artifactId>arquillian-jbossas-managed-5.1</artifactId>
<version>1.0.0.CR3</version>
</dependency>
<dependency>
<groupId>org.jboss.jbossas</groupId>
<artifactId>jboss-server-manager</artifactId>
<version>1.0.3.GA</version>
</dependency>
<dependency>
<groupId>org.jboss.jbossas</groupId>
<artifactId>jboss-as-client</artifactId>
<version>5.1.0.GA</version>
<type>pom</type>
</dependency>
</dependencies>
</profile>
</profiles>
</project>
How to map my ejbs in order to be able to test them in my Arquillian project?
You have a couple of options.
If your EJB and other JAR are deployed separately to your app, you can use multiple deployments in your test case. Only one is "testable" but both can be deployed. You can simplify the reading of this external JAR file using ShrinkWrap's maven resolver.
If they are wrapped in to a WAR or EAR, just use that WAR or EAR as your deployment.