I'm trying to load a global shared library using the #Library("xxx") annotation.
The "Retrieval method" in the global settings is set to "Git".
The library is located in a subfolder within the git repository, e.g.:
my-library
+-- src
+-- com
+ ...
When starting the build, jenkins loads the complete repository and looks for the "src" folder in the root directory. I got the following error message:
ERROR: Library xxx expected to contain at least one of src or vars directories"
However, I want Jenkins to use the library from the "my-library" subfolder
Related
my-project
|
|-kube
|_kustomize
|_base
|_sql
|_dbsturct
|_liqubase
|-db.changelog-master.xml
|-src
|_my.java.code
|_ resources
In my project I kept database-chagelog.xml outside resources folder and not included in the classpath.This folder structure is not included in the pom.xml as part of resources.
I have configured spring.liquibase.change-log=file:///C:/my-project/kube/kustomize/base/sql/dbsruct/liquibase/db.changelog-master.xml
It throws file not found exception.
Is there a way to configure db.changelog-master.xml without including as resource folder inside pom.xml?
I have a Golang project with one git submodule like follows:
Project
go.mod
main.go
config.go
go-blockchain/ (git Submodule)
go.mod
crypto/
encode.go (This has cgo code in it)
crypto.go
main.go
When I run go build at the top level, I get errors like:
# github.com/blockchain/go-blockchain/crypto
/Users/niceguy/.go/pkg/mod/github.com/blockchain/go-blockchain#v0.0.0-20200320145517-cea8009ba7ee/crypto/encode.go:86:2: could not determine kind of name for C.crypto_encode_pair
/Users/niceguy/.go/pkg/mod/github.com/blockchain/go-blockchain#v0.0.0-20200320145517-cea8009ba7ee/crypto/encode.go:80:2: could not determine kind of name for C.crypto_encode_from_seed
/Users/niceguy/.go/pkg/mod/github.com/blockchain/go-blockchain#v0.0.0-20200320145517-cea8009ba7ee/crypto/encode.go:115:9: could not determine kind of name for C.crypto_encode_proof_to_hash
The problem appears to be that I'm favoring the cache over the CGO libraries that are built and deposited back in the go-blockchain folder.
Suggestions?
The structure of my Gradle project is the following:
Project
├── app
└── build.gradle
├── foo
└── bar.txt
·
·
·
└── build.gradle
Normally to get the absolute path of the foo folder I can just simply do new File('foo').getAbsolutePath() in the root build.gradle file.
But this unfortunately doesn't work if you run the gradle script from outside the project directory, for example doing something like this:
$ trunk/gradlew -b trunk/build.gradle tasks
With the previous command gradle is looking for the foo directory in the parent of the Project, because I started the script from there.
Is there a way to get the absolute path of the Project where the build.gradle is, even if you start your script from another directory? Or is there any other way to get a reference of a directory in the same folder where the script is?
I've tried also with getClass().protectionDomain.codeSource.location.path but it is returning the path to the gradle cache directory.
I got past this problem by ensuring Java userDir was set to the project directory (i.e. project.projectDir) at the top of my build.gradle file, as follows:
System.setProperty( "user.dir", project.projectDir.toString() )
println " project dir: "+ System.getProperty("user.dir");
This can be checked by executing a separate (Groovy) code file such as:
println "User Dir: ${System.getProperty( 'user.dir' )}"
You can output the Gradle project values before and after using these statements.
println "Root project: ${project.rootProject}";
println " rootDir: ${project.rootDir}"
println " projectDir: ${project.projectDir}";
println " project dir: ${System.getProperty("user.dir")}";
If you have sub-projects, projectDir is not the same as rootDir.
This hasn't fixed my actual problem but it has ensured that I'm opening the correct file (relative to the location of build.gradle.
new File('foo') by definition (look at its JavaDoc) makes a path relative to the current working directory, so depends on where you call the app from. If you want a path relative to the project folder, use project.file('foo'), or as project is the default for resolving the method just file('foo') and you get the relative path resolved against the project directory, not the working directory. So use file('foo').absolutePath and you will be fine.
In the build.gradle file just use projectDir to get the absolute path of the build.gradle file. from there you can navigate your project's files. read this for more info:
https://www.tutorialspoint.com/gradle/gradle_build_script.htm
I was using new File() and path to get the source directory into the gradle file but in Macbook with M1 Chip it's not working, let me share the code for previous and new version:
Older code:
new File("app/src/")
Updated code:
new File(project.projectDir.getAbsolutePath() + "/src/")
I have a project with folders structure:
d:/gopath/src/github.com/
...packages
d:/projects/src/myproject/
main.go
/submodule1/
...go files
/submodule2/
...go files
GOPATH is d:/gopath;d:/master
I hava import & use submodule1 and submodule2 in main.go of myproject
Then I execute command govendor init and govendor add +external to generate vendor files.
But strange things happend, I found that there is a myproject folder in the vendor folder
I have try to create a new folder named mymain to hold main.go,then try again.this time there are not any files in the folder vendor except vendor.json
I have created a package named go-orm in golang and its structure is follows.
go-orm
--| mine.go
--| src
-----| src.go
-----| db
--------| DBConnection.go
When I ran the command "go install" in go-orm directory, it created only
go-orm.a but not src.a and db.a (sub directories or packages). When I checked
"go install" with mgo package it created .a files for it's sub directory "bson".
I need the same functionality for my package. What change is needed in my
package to make this possible.
Edit 1
my package is in GOPATH/src/ directory. All my sub packages(src and db) exist.
Package build
Go Path
The Go path is a list of directory trees containing Go source code. It
is consulted to resolve imports that cannot be found in the standard
Go tree. The default path is the value of the GOPATH environment
variable, interpreted as a path list appropriate to the operating
system (on Unix, the variable is a colon-separated string; on Windows,
a semicolon-separated string; on Plan 9, a list).
Each directory listed in the Go path must have a prescribed structure:
The src/ directory holds source code. The path below 'src' determines
the import path or executable name.
The pkg/ directory holds installed package objects. As in the Go tree,
each target operating system and architecture pair has its own
subdirectory of pkg (pkg/GOOS_GOARCH).
If DIR is a directory listed in the Go path, a package with source in
DIR/src/foo/bar can be imported as "foo/bar" and has its compiled form
installed to "DIR/pkg/GOOS_GOARCH/foo/bar.a" (or, for gccgo,
"DIR/pkg/gccgo/foo/libbar.a").
The bin/ directory holds compiled commands. Each command is named for
its source directory, but only using the final element, not the entire
path. That is, the command with source in DIR/src/foo/quux is
installed into DIR/bin/quux, not DIR/bin/foo/quux. The foo/ is
stripped so that you can add DIR/bin to your PATH to get at the
installed commands.
Here's an example directory layout:
GOPATH=/home/user/gocode
/home/user/gocode/
src/
foo/
bar/ (go code in package bar)
x.go
quux/ (go code in package main)
y.go
bin/
quux (installed command)
pkg/
linux_amd64/
foo/
bar.a (installed package object)
Use the prescribed directory structure, including the use of src as a directory name. Follow the example. Don't use src, pkg, or bin as package names.
go-orm
--| mine.go
--| src <== !? Don't use src as a package name.
-----| src.go
-----| db
--------| DBConnection.go
After long analysis I found that "import" statement in root directory go file
can do the trick. I created one extra file named create_archieve.go in root
directory(go-orm). Inside that I just inserted the following lines which created
go-orm.a, src.a and db.a.
create_archieve.go
package nosql_orm
import _"go-orm/src/db"